Job Command
#1

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 .
Reply
#2

Create enumeration, then define global or PVar that indicates player job, and lastly check it. Need code example?
Reply
#3

Yes , I do .
Reply
#4

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)
Reply
#5

I have to put them in order , or one somewhere and another somewhere ? Or after the command?
Reply
#6

Код:
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;
}
Reply
#7

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 ?
Reply
#8

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.
Reply
#9

I understand , but how to check if it's the right player/checkpoint?
Reply
#10

Just check if the player is in a checkpoint and if his job is pizzaguy, if he is run the timer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)