Please help with making jobs -
Gavin - 24.11.2010
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
Re: Please help with making jobs -
Leeroy. - 24.11.2010
Click Here !
Re: Please help with making jobs -
Gavin - 24.11.2010
Thankyou very much
Re: Please help with making jobs -
Gavin - 24.11.2010
Hmm.. how to make commands that only a certain jobs can use?
Re: Please help with making jobs -
<Weponz> - 24.11.2010
Quote:
Originally Posted by leeroy1337
|
The message you have entered is too short. Please lengthen your message to at least 8 characters.
Re: Please help with making jobs -
Gavin - 24.11.2010
mmm I know, but how do i make commands that only certain jobs can use. I don't see it there? D:
Re: Please help with making jobs -
iggy1 - 24.11.2010
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
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.
Re: Please help with making jobs -
Gavin - 24.11.2010
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?
Re: Please help with making jobs -
iggy1 - 24.11.2010
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;
}
Re: Please help with making jobs -
Gavin - 24.11.2010
Hey iggy I am a bit confused i have sent you a PM to help me. Thankyou