SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/01/2020, 06:22 PM   #1
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Exclamation Help me with the command /duty

Good morning, afternoon or night the time you see this, I need help in the code that will show them the function of this is that you put "/ duty" and activate your administrator mode that only when you are in / duty do you have the permissions if / ban, / kick and those but I could only create the command but I don't know how to set certain commands for the ones I said earlier and some more.

some commands that I want them to put in the code by putting "/ duty"

/ban
/kick
/jet

PHP Code:
#include <a_samp>

new
    
p_onDuty[MAX_PLAYERS] = 0,
    
p_oldSkin[MAX_PLAYERS] = -1
;

public 
OnFilterScriptInit()
{
    print(
"Duty system.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
p_onDuty[playerid] = 0;
    
p_oldSkin[playerid] = -1;
    return 
1;
}

public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/duty"cmdtexttrue5) == 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(playeridp_Name24); //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(playerid283); //Change this to the skin ID you want!

            
GivePlayerWeapon(playerid24100); //Gives them a desert eagle with 100 ammo.

            
SetPlayerArmour(playerid100); //Set their armour to 100!

            
format(stringsizeof(string), "*Service"p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        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(playeridp_oldSkin[playerid]); //Setting their old skin back!
            
p_oldSkin[playerid] = -1//Resetting the skin variable

            
SetPlayerArmour(playerid0); //Resetting their armour

            
format(stringsizeof(string), "*[-]Service."p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        return 
1;
    }
    return 
0;

The others will look for them and I will add them so as not to annoy those who could help me
J4weno is offline   Reply With Quote
Old 02/01/2020, 06:31 PM   #2
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 278
Reputation: 8
Default Re: Help me with the command /duty

I can not understand what you mean.
Do you want only duty administrators can use the /Ban, /Kick, and /Jet commands?
Vizi10 is offline   Reply With Quote
Old 02/01/2020, 06:43 PM   #3
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Default Re: Help me with the command /duty

Quote:
Originally Posted by Vizi10 View Post
I can not understand what you mean.
Do you want only duty administrators can use the /Ban, /Kick, and /Jet commands?
Yes sorry if I do not explain well
J4weno is offline   Reply With Quote
Old 02/01/2020, 06:59 PM   #4
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Help me with the command /duty

PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
new
    
p_onDuty[MAX_PLAYERS] = 0,
    
p_oldSkin[MAX_PLAYERS] = -1
;


public 
OnFilterScriptInit()
{
    print(
"Duty system.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
p_onDuty[playerid] = 0;
    
p_oldSkin[playerid] = -1;
    return 
1;
}

CMD:duty(playerid,params)
{
        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(playeridp_Name24); //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(playerid283); //Change this to the skin ID you want!

            
GivePlayerWeapon(playerid24100); //Gives them a desert eagle with 100 ammo.

            
SetPlayerArmour(playerid100); //Set their armour to 100!

            
format(stringsizeof(string), "*Service"p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        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(playeridp_oldSkin[playerid]); //Setting their old skin back!
            
p_oldSkin[playerid] = -1//Resetting the skin variable

            
SetPlayerArmour(playerid0); //Resetting their armour

            
format(stringsizeof(string), "*[-]Service."p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        return 
1;
}

CMD:ban(playeridparams[])
{

    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/ban <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been banned by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Ban(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:kick(playeridparams[])
{

    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/kick <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been kicked by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Kick(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:jp(playerid,params[])
{
   if(
p_onDuty[playerid] == 1)
   {
     
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USEJETPACK);
     
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}You have got a jetpack!");
     
PlayerPlaySound(playerid11490.00.010.0);
   }
   else
   {
   
SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
   }
   return 
1;

use zcmd to facilitate making a command, and also sscanf.
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 02/01/2020, 07:14 PM   #5
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Default Re: Help me with the command /duty

Quote:
Originally Posted by Flofey View Post
PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
new
    
p_onDuty[MAX_PLAYERS] = 0,
    
p_oldSkin[MAX_PLAYERS] = -1
;


public 
OnFilterScriptInit()
{
    print(
"Duty system.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
p_onDuty[playerid] = 0;
    
p_oldSkin[playerid] = -1;
    return 
1;
}

CMD:duty(playerid,params)
{
        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(playeridp_Name24); //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(playerid283); //Change this to the skin ID you want!

            
GivePlayerWeapon(playerid24100); //Gives them a desert eagle with 100 ammo.

            
SetPlayerArmour(playerid100); //Set their armour to 100!

            
format(stringsizeof(string), "*Service"p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        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(playeridp_oldSkin[playerid]); //Setting their old skin back!
            
p_oldSkin[playerid] = -1//Resetting the skin variable

            
SetPlayerArmour(playerid0); //Resetting their armour

            
format(stringsizeof(string), "*[-]Service."p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        return 
1;
}

CMD:ban(playeridparams[])
{

    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/ban <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been banned by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Ban(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:kick(playeridparams[])
{

    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/kick <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been kicked by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Kick(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:jp(playerid,params[])
{
   if(
p_onDuty[playerid] == 1)
   {
     
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USEJETPACK);
     
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}You have got a jetpack!");
     
PlayerPlaySound(playerid11490.00.010.0);
   }
   else
   {
   
SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You aren't authorized to use this command!");
   }
   return 
1;

use zcmd to facilitate making a command, and also sscanf.
Uff nice, Thank you.
J4weno is offline   Reply With Quote
Old 02/01/2020, 07:26 PM   #6
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Default Re: Help me with the command /duty

It works perfectly, but something that I forgot to comment on is that I want that through a folder I can put admin to a player or by a CMD but that if you do not have that command set I can not use / duty sorry if I bother you a lot if you can thank me If not, then there is no problem.
J4weno is offline   Reply With Quote
Old 02/01/2020, 07:37 PM   #7
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Help me with the command /duty

Quote:
Originally Posted by J4weno View Post
It works perfectly, but something that I forgot to comment on is that I want that through a folder I can put admin to a player or by a CMD but that if you do not have that command set I can not use / duty sorry if I bother you a lot if you can thank me If not, then there is no problem.
this is a command for setting someone on/off duty, once you set him and want him to go off duty just type again /setduty with his id and it will be disabled.

PHP Code:
CMD:setduty(playerid,params)
{
    if(
IsPlayerAdmin(playerid))//once ur logged in rcon u can use it
    
{
        if(
p_onDuty[pID] == 0)
        {
        new 
pIDstr[144],tname[MAX_PLAYER_NAME];
        if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/setduty <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(pIDtnamesizeof(tname));
        
format(strsizeof(str), "[BAN] {ffa700}%s has been set on duty{F00f00}",tname);
        
p_OnDuty[pID] = 1;
        
SendClientMessageToAll(0xf8f8f8fffstr);
        }
        else
        {
        if(
p_onDuty[pID] == 1)
        {
        new 
pIDstr[144],tname[MAX_PLAYER_NAME];
        if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/setduty <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(pIDtnamesizeof(tname));
        
format(strsizeof(str), "[BAN] {ffa700}%s has been set off duty{F00f00}",tname);
        
p_OnDuty[pID] = 0;
        
SendClientMessageToAll(0xf8f8f8fffstr);
        }
        }
 
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

haven't tested it anyways,

btw about a file which you where you'll be able to set someone's duty i don't think it's possible without using a database.
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 02/01/2020, 07:55 PM   #8
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Default Re: Help me with the command /duty

Let me explain what I want is that if he enters for the first time and says "/ duty" he says that he is not authorized, but that if I put in the main console Example: / setduty Ryan_Spell the / setduty is the cmd and the Ryan_Spell is the name of the entity he can use the "/ duty" and everything above is met
J4weno is offline   Reply With Quote
Old 02/01/2020, 08:34 PM   #9
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Help me with the command /duty

Quote:
Originally Posted by J4weno View Post
Let me explain what I want is that if he enters for the first time and says "/ duty" he says that he is not authorized, but that if I put in the main console Example: / setduty Ryan_Spell the / setduty is the cmd and the Ryan_Spell is the name of the entity he can use the "/ duty" and everything above is met
Okay now try this:

PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
new
    
p_onDuty[MAX_PLAYERS] = 0,
    
p_oldSkin[MAX_PLAYERS] = -1
    capable
[MAX_PLAYERS];
;


public 
OnFilterScriptInit()
{
    print(
"Duty system.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
p_onDuty[playerid] = 0;
    
p_oldSkin[playerid] = -1;
    return 
1;
}

CMD:duty(playerid,params)
{
    if(
capable[playerid] == 1)
    {

        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(playeridp_Name24); //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(playerid283); //Change this to the skin ID you want!

            
GivePlayerWeapon(playerid24100); //Gives them a desert eagle with 100 ammo.

            
SetPlayerArmour(playerid100); //Set their armour to 100!

            
format(stringsizeof(string), "*Service"p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        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(playeridp_oldSkin[playerid]); //Setting their old skin back!
            
p_oldSkin[playerid] = -1//Resetting the skin variable

            
SetPlayerArmour(playerid0); //Resetting their armour

            
format(stringsizeof(string), "*[-]Service."p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
        return 
1;
    }
}

CMD:ban(playeridparams[])
{
    if(
capable[playerid] == 1)
    {
    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/ban <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been banned by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Ban(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You need to be on duty to use this command!");
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:kick(playeridparams[])
{
    if(
capable[playerid] == 1)
    {
    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/kick <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been kicked by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Kick(pID);
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You need to be on duty to use this command!");
    }
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:jp(playerid,params[])
{
   if(
capable[playerid] == 1)
   {
   if(
p_onDuty[playerid] == 1)
   {
     
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USEJETPACK);
     
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}You have got a jetpack!");
     
PlayerPlaySound(playerid11490.00.010.0);
   }
   else
   {
        
SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You need to be on duty to use this command!");
   }
   }
   else
   {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
   }
   return 
1;


CMD:capability(playerid,params//only rcon can use it to set someone able to be on duty.
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
idstring[128], tname[MAX_PLAYER_NAME]
        if(
capable[id] == )
        {
        if(
sscanf(params"u"id)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/capability <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(id,tnamesizeof(tname));
        
format(stringsizeof(string),"[INFO] {FFFFFF}%s(%i) is now capable to be on duty!",tname,id);
        
SendClientMessage(playerid,0xf8f8f8fff,string);
        
capable[id] = 1;
        }
        else
        {
        if(
capable[id] == )
        {
        if(
sscanf(params"u"id)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/capability <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(id,tnamesizeof(tname));
        
format(stringsizeof(string),"[INFO] {FFFFFF}%s(%i) is now not capable to be on duty!",tname,id);
        
SendClientMessage(playerid,0xf8f8f8fff,string);
        
capable[id] = 0;
        }
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

/capable <ID> is a command that can be used once you're logged in as rcon admin, it's function is to give someone the capability to use /duty and every single command related to it, once you changed your mind and want this person to stop being able to be on duty simply type /capable <ID> again and it will dis-allow him to be on duty neither use the commands of it.
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 02/01/2020, 09:44 PM   #10
J4weno
Little Clucker
 
Join Date: Dec 2019
Posts: 7
Reputation: 0
Default Re: Help me with the command /duty

Quote:
Originally Posted by Flofey View Post
Okay now try this:

PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
new
    
p_onDuty[MAX_PLAYERS] = 0,
    
p_oldSkin[MAX_PLAYERS] = -1
    capable
[MAX_PLAYERS];
;


public 
OnFilterScriptInit()
{
    print(
"Duty system.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    return 
1;
}

public 
OnPlayerConnect(playerid)
{
    
p_onDuty[playerid] = 0;
    
p_oldSkin[playerid] = -1;
    return 
1;
}

CMD:duty(playerid,params)
{
    if(
capable[playerid] == 1)
    {

        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(playeridp_Name24); //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(playerid283); //Change this to the skin ID you want!

            
GivePlayerWeapon(playerid24100); //Gives them a desert eagle with 100 ammo.

            
SetPlayerArmour(playerid100); //Set their armour to 100!

            
format(stringsizeof(string), "*Service"p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
        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(playeridp_oldSkin[playerid]); //Setting their old skin back!
            
p_oldSkin[playerid] = -1//Resetting the skin variable

            
SetPlayerArmour(playerid0); //Resetting their armour

            
format(stringsizeof(string), "*[-]Service."p_Name);
            return 
SendClientMessageToAll(0xE0941BFFstring);
        }
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
        return 
1;
    }
}

CMD:ban(playeridparams[])
{
    if(
capable[playerid] == 1)
    {
    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/ban <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been banned by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Ban(pID);
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You need to be on duty to use this command!");
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:kick(playeridparams[])
{
    if(
capable[playerid] == 1)
    {
    new 
pIDstr[144],pname[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME];
    if(
p_onDuty[playerid] == 1)
    {
    if(
sscanf(params"us"pIDparams)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/kick <ID> <Reason>");
    if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(pIDtnamesizeof(tname));
    
format(strsizeof(str), "[BAN] {ffa700}%s has been kicked by an administrator {F00f00}[REASON: %s]",tname,params);
    
SendClientMessageToAll(0xf8f8f8fffstr);
    
Kick(pID);
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You need to be on duty to use this command!");
    }
    }
    else
    {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;
}

CMD:jp(playerid,params[])
{
   if(
capable[playerid] == 1)
   {
   if(
p_onDuty[playerid] == 1)
   {
     
SetPlayerSpecialAction(playeridSPECIAL_ACTION_USEJETPACK);
     
SendClientMessage(playerid0xf8f8f8fff,"[ADMIN] {FFFFFF}You have got a jetpack!");
     
PlayerPlaySound(playerid11490.00.010.0);
   }
   else
   {
        
SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}You need to be on duty to use this command!");
   }
   }
   else
   {
        
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
   }
   return 
1;


CMD:capability(playerid,params//only rcon can use it to set someone able to be on duty.
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
idstring[128], tname[MAX_PLAYER_NAME]
        if(
capable[id] == )
        {
        if(
sscanf(params"u"id)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/capability <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(id,tnamesizeof(tname));
        
format(stringsizeof(string),"[INFO] {FFFFFF}%s(%i) is now capable to be on duty!",tname,id);
        
SendClientMessage(playerid,0xf8f8f8fff,string);
        
capable[id] = 1;
        }
        else
        {
        if(
capable[id] == )
        {
        if(
sscanf(params"u"id)) return SendClientMessage(playerid0xf8f8f8fff"Syntax: {FFFFFF}/capability <ID>");
        if(!
IsPlayerConnected(pID) || pID == INVALID_PLAYER_ID) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}That player is not connected");
        
GetPlayerName(id,tnamesizeof(tname));
        
format(stringsizeof(string),"[INFO] {FFFFFF}%s(%i) is now not capable to be on duty!",tname,id);
        
SendClientMessage(playerid,0xf8f8f8fff,string);
        
capable[id] = 0;
        }
    }
    else
    {
    
SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    }
    return 
1;

/capable <ID> is a command that can be used once you're logged in as rcon admin, it's function is to give someone the capability to use /duty and every single command related to it, once you changed your mind and want this person to stop being able to be on duty simply type /capable <ID> again and it will dis-allow him to be on duty neither use the commands of it.
PHP Code:
C:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(7) : error 001expected token";"but found "-identifier-"
C:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(30) : error 017undefined symbol "capable"
C:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(30) : warning 215expression has no effect
C
:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(30) : error 001expected token";"but found "]"
C:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(30) : error 029invalid expressionassumed zero
C
:\Users\BrayanaPC\Desktop\23\filterscripts\Untitled.pwn(30) : fatal error 107too many error messages on one line 
Line 30
J4weno is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
duty command GeneralAref Scripting Help 1 13/12/2015 11:45 AM
[on duty] Command Help basse Scripting Help 15 15/11/2012 09:23 PM
Duty Command UnknownGamer Scripting Help 0 08/09/2012 09:32 PM
/duty command ThamburaaN Scripting Help 9 22/09/2011 11:24 AM
Saving duty when disconnecting (you'll return on duty if you were on duty) Chivava Help Archive 7 04/02/2010 10:18 AM


All times are GMT. The time now is 04:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.