Trying to get a duty system
#2

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;
}
Reply


Messages In This Thread
Trying to get a duty system - by Captain_jeffree95 - 16.01.2012, 02:07
Re: Trying to get a duty system - by Scarred - 16.01.2012, 03:01

Forum Jump:


Users browsing this thread: 1 Guest(s)