UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: arceus on October 23, 2014, 02:31:50 pm

Title: get a specific player
Post by: arceus on October 23, 2014, 02:31:50 pm
I was just wondering how i could get player 1 or 2 or 3 or 4 through script so if player 1 activates a trigger it will be different then when player 2 does it?
Title: Re: get a specific player
Post by: PROxFTW on October 23, 2014, 02:43:58 pm
Something along the lines of this should do it.
Code Snippet
Plaintext
// Example script. Depending on certain things GetEntArray would be better but make sure to thread that and set the values to self
// threading: thread TrigStuff();
// array threading: Trigs = GetEntArray( "TrigPlay", "targetname" ); for( i = 0; i < Trigs.size; i++ ) Trigs[i] thread TrigStuff();
TrigStuff()
{
// If use array comment below out
Trig = GetEnt( "TrigPlay", "targetname" );
while( 1 )
{
// If use array comment below out
Trig waittill( "trigger", user );
// Uncomment below if using array
// self waittill( "trigger", user );
if( user == GetPlayers()[0] )
{
// Player 1
}
else if( user == GetPlayers()[1] )
{
// Player 2
}
else if( user == GetPlayers()[2] )
{
//Player 3
}
else if( user == GetPlayers()[3] )
{
//Player 4
}
}
}
Title: Re: get a specific player
Post by: BluntStuffy on October 23, 2014, 02:44:51 pm
EDIT:

Loool, PRO you beat by a few sec there. i removed mine since it was kinda the same..  ;D

Title: Re: get a specific player
Post by: arceus on October 23, 2014, 02:45:11 pm
Something along the lines of this should do it.
Code Snippet
Plaintext
// Example script. Depending on certain things GetEntArray would be better but make sure to thread that and set the values to self
// threading: thread TrigStuff();
// array threading: Trigs = GetEntArray( "TrigPlay", "targetname" ); Trigs[i] thread TrigStuff();
TrigStuff()
{
// If use array comment below out
Trig = GetEnt( "TrigPlay", "targetname" );
while( 1 )
{
// If use array comment below out
Trig waittill( "trigger", user );
// Uncomment below if using array
// self waittill( "trigger", user );
if( user == GetPlayers()[0] )
{
// Player 1
}
else if( user == GetPlayers()[1] )
{
// Player 2
}
else if( user == GetPlayers()[2] )
{
//Player 3
}
else if( user == GetPlayers()[3] )
{
//Player 4
}
}
}
thanks :D that was fast ill try it latter when i get home :D