Trying to get a duty system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Trying to get a duty system (
/showthread.php?tid=311321)
Trying to get a duty system -
Captain_jeffree95 - 16.01.2012
heyy guys just a quick can some make a admin duty system or can some one post the code is this thread cause i really need one and when we make it it does work please help.
with the cmds
/aduty - turns admin cmds on and show whitch admins are online
/aoffduty - turns admin cmds off and doesnt show witch admins are on
Re: Trying to get a duty system -
Scarred - 16.01.2012
Here you are, whipped it up in about 5 minutes for you, it's a filterscript. Feel free to add upon it, I even commented some things you need to edit to your liking.
pawn Код:
#include <a_samp>
new
p_onDuty[MAX_PLAYERS] = 0,
p_oldSkin[MAX_PLAYERS] = -1
;
public OnFilterScriptInit()
{
print("Simple duty system by Scarred started.");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
p_onDuty[playerid] = 0;
p_oldSkin[playerid] = -1;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/duty", cmdtext, true, 5) == 0)
{
new
string[128], //SA:MP does not send client messages over 128 characters.
p_Name[24] //24 is the maximum length for nicknames in SA:MP 0.3d (Could increase in later versions?)
;
GetPlayerName(playerid, p_Name, 24); //Could also do: GetPlayerName(playerid, p_Name, sizeof(p_Name));
if(p_onDuty[playerid] == 0) { //Checking if their On Duty variable is zero (0) [They are off duty]
p_onDuty[playerid] = 1;
//You can add the rest of your on duty code here, e.g: Giving them weapons, a police skin, ect. Here, we will save their skin, and set their skin to a police skin.
p_oldSkin[playerid] = GetPlayerSkin(playerid);
SetPlayerSkin(playerid, 283); //Change this to the skin ID you want!
GivePlayerWeapon(playerid, 24, 100); //Gives them a desert eagle with 100 ammo.
SetPlayerArmour(playerid, 100); //Set their armour to 100!
format(string, sizeof(string), "* Officer %s has went on duty!", p_Name);
return SendClientMessageToAll(0xE0941BFF, string);
}
else if(p_onDuty[playerid] == 1) { //Checking if their On Duty variable is one (1) [They are on duty]
p_onDuty[playerid] = 0;
ResetPlayerWeapons(playerid); //Takes away all their weapons!
SetPlayerSkin(playerid, p_oldSkin[playerid]); //Setting their old skin back!
p_oldSkin[playerid] = -1; //Resetting the skin variable
SetPlayerArmour(playerid, 0); //Resetting their armour
format(string, sizeof(string), "* Officer %s has went off duty!", p_Name);
return SendClientMessageToAll(0xE0941BFF, string);
}
return 1;
}
return 0;
}