Job Command -
DanBike - 21.07.2011
Hello , I made a command , and I want to use it for a job , so only players that got that job would use it . I don't know how to do that . But here is the command :
Код:
if (strcmp("/startwork", cmdtext, true, 10) == 0)
{
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
return 1;
}
return 0;
}
I didn't put the coords yet , but I want this command to work for the player only if the player has that job for example : Pizzaboy .
Re: Job Command -
RSX - 21.07.2011
Create enumeration, then define global or PVar that indicates player job, and lastly check it. Need code example?
Re: Job Command -
DanBike - 21.07.2011
Yes , I do .
Re: Job Command -
RSX - 21.07.2011
pawn Код:
enum pJobs {
Pizzaboy,
Taxi
};
enum pData {
pJobs:Job,
_:Cash
};
new global_array_for_players[MAX_PLAYERS][pData]; // To optimize you can use the actual limit
To assign :
pawn Код:
global_array_for_players[playerid][Job]=Pizzaboy;
To check :
pawn Код:
if(global_array_for_players[playerid][Job]==Pizzaboy)
Re: Job Command -
DanBike - 21.07.2011
I have to put them in order , or one somewhere and another somewhere ? Or after the command?
Re: Job Command -
Niixie - 21.07.2011
Код:
if (strcmp("/startwork", cmdtext, true, 10) == 0)
{
if(global_array_for_players[playerid][Job]==Pizzaboy)
{
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
return 1;
}
}
return 0;
}
And if you want more jobs, you can do like this:
Код:
if (strcmp("/startwork", cmdtext, true, 10) == 0)
{
if(global_array_for_players[playerid][Job]==Pizzaboy)
{
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
return 1;
}
else if(global_array_for_players[playerid][Job]==Taxi)
{
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
return 1;
}
}
return 0;
}
Re: Job Command -
DanBike - 21.07.2011
Thank you very much Niixie , how could I set a timer when the player gets there and gets in the checkpoint? A timer that holds the player in the checkpoint for like 5 minutes ?
Re: Job Command -
RSX - 21.07.2011
You'd need to do it like this :
OnPlayerEnterCheckpoint
Check if it's the right player/checkpoint(if they're streamed) and then
you'd start some idling process (such as being frozen with TogglePlayerControllable) and add your timer :
SetTimer( "your_public_function" , runs only once )
public your_public_function(playerid)
{
Here you'd stop your idling process (such as unfreezing player) and probably give further commands, for instance the next checkpoint.
}
If you didn't understand it yet (I really hope you did) someone or I could write short example of this.
Re: Job Command -
DanBike - 21.07.2011
I understand , but how to check if it's the right player/checkpoint?
Re: Job Command -
Niixie - 27.07.2011
Just check if the player is in a checkpoint and if his job is pizzaguy, if he is run the timer.