Please help with making jobs
#1

Hello, I am new to scripting and i was wondering how do i make jobs like police and stuff. So like when they press spawn on cop skin it spawns them in police station, and gives them weapons, but only for police. and I wanna make commands for just police.. Hopefully you know what I mean.. please help?

- Gavin
Reply
#2

Click Here !
Reply
#3

Thankyou very much
Reply
#4

Hmm.. how to make commands that only a certain jobs can use?
Reply
#5

Quote:
Originally Posted by leeroy1337
Посмотреть сообщение
The message you have entered is too short. Please lengthen your message to at least 8 characters.
Reply
#6

mmm I know, but how do i make commands that only certain jobs can use. I don't see it there? D:
Reply
#7

You would need to use a variable for each job in my example ill use one (police).
At the top of your code but underneath your includes and defines make the variables.
pawn Код:
new ispolice[MAX_PLAYERS];
Then you need to go where you give the player a job and assign the players slot to 1 like this
pawn Код:
ispolice[playerid] = 1;
Now inside any command you can do the following.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!ispolice[playerid]))return SendClientMessage(playerid, 0xff0000FF, "ERROR: You are not in the police force");//if police[playerid] has no value, send error message
        return 1;
    }
    return 0;
}
The important thing is make sure this is at the top of your command. It will prevent a player using the command by returning an error message.
pawn Код:
if(!ispolice[playerid]))return SendClientMessage(playerid, 0xff0000FF, "ERROR: You are not in the police force");
I hope this is clear enough for you if not at least i tried seems like you need to read some more tutorials as stated above.
Reply
#8

Okay, so after i do the error message thing at the top of the command I can do stuff that cops can only do, Correct?
Reply
#9

If you if you assign the variable to 1, when you give the job. Then only police should be able to do the command because if the variable equals 0 (or less) it will return an error message.

EDIT: And dont forget to reset the variable onplayerdisconnect. And/or when they quit the job.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    ispolice[playerid] = 0;
    return 1;
}
Reply
#10

Hey iggy I am a bit confused i have sent you a PM to help me. Thankyou
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)