/duty Bugged
#1

GUys When i Use /duty he said admin onduty But if use /duty to OffDuty ican't OnDuty Again


PHP код:
YCMD:duty(playeridparams[], help)
{
        
#pragma unused help
        #pragma unused params
        
if(P_Data[playerid][pAdmin] == 3) return SCM(playeridCOLOR_RED"You aren't an admin!");
        new
            
string[128];
        if(
P_Data[playerid][pDuty] == 3) {
        
SetPlayerHealth(playerid,100);
        
SetPlayerColor(playerid,-1);
        
format(string,sizeof(string)," {FF0000} %s is now off Duty!",GetName(playerid));
        
SCMToAll(-1,string); P_Data[playerid][pDuty] = 3;}
        else {
        
format(string,sizeof(string)," {FF0000} %s is now on Duty!",GetName(playerid));
        
SetPlayerHealth(playerid,99999);
        
SetPlayerColor(playerid,0xFF000000);
        
SCMToAll(-1,string); P_Data[playerid][pDuty] = 3;}
        return 
1;

Reply
#2

Help?
Reply
#3

Код:
New AdminDuty[MAX_PLAYERS];//Put onplayerspawn AdminDuty[playerid] = 0;
CMD:duty(playerid,params[])
{
//Put check if is player admin
if(AdminDuty[playerid] == 0)
{
SCM(playerid,-1,"You Are On Duty");
AdminDuty[playerid] = 1;
}
else if(AdminDuty[playerid] == 1)
{
SCM(playerid,-1,"You Are Off Duty");
AdminDuty[playerid] = 0;
}
return 1;
}
I Think this shud work
Reply
#4

pawn Код:
YCMD:duty(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        if(P_Data[playerid][pAdmin] == 3) return SCM(playerid, COLOR_RED, "You aren't an admin!");
        new
            string[128];
        if(P_Data[playerid][pDuty] == 3) {
        SetPlayerHealth(playerid,100);
        SetPlayerColor(playerid,-1);
        format(string,sizeof(string)," {FF0000} %s is now off Duty!",GetName(playerid));
        SCMToAll(-1,string); P_Data[playerid][pDuty] = 2;} // this line is your problem just change the "P_Data[playerid][pDuty]=2" << to your off duty number
        else {
        format(string,sizeof(string)," {FF0000} %s is now on Duty!",GetName(playerid));
        SetPlayerHealth(playerid,99999);
        SetPlayerColor(playerid,0xFF000000);
        SCMToAll(-1,string); P_Data[playerid][pDuty] = 3;}
        return 1;
}
Reply
#5

pawn Код:
new duty[MAX_PLAYERS];
//somewhere under the includes, etc

public OnPlayerConnect(playerid)
{
    duty[playerid] =0;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    duty[playerid] =0;
    return 1;
}

public OnPlayerDeath(playerid,killerid,reason)
{
    duty[playerid] =0;
        return 1;
}

public OnPlayerSpawn(playerid)
{
    duty[playerid] =0;
        return 1;
}


YCMD:duty(playerid, params[], help)
{
    #pragma unused help
    #pragma unused params
    if(P_Data[playerid][pAdmin] == 3) return SCM(playerid, COLOR_RED, "You aren't an admin!");
    else
    {
        if(duty[playerid] == 1)
        {
            new string[128];
            SetPlayerHealth(playerid,100);
            SetPlayerColor(playerid,-1);
            format(string,sizeof(string)," {FF0000} %s is now off Duty!",GetName(playerid));
            SCMToAll(-1,string); P_Data[playerid][pDuty] = 3;}
            duty[playerid] =1;
        }
        else
        {
            format(string,sizeof(string)," {FF0000} %s is now on Duty!",GetName(playerid));
            SetPlayerHealth(playerid,99999);
            SetPlayerColor(playerid,0xFF000000);
            SCMToAll(-1,string);
            P_Data[playerid][pDuty] = 3;
        }
    }
    return 1;
}
A more simpler way of doing things so that nothing really gets crossed up.
Reply
#6

I have no idea why did you create the same topic, but okay.
http://forum.sa-mp.com/showthread.ph...04#post3249404
Let's answer this one more time.
pawn Код:
YCMD:duty(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        if(P_Data[playerid][pAdmin] == 3) return SCM(playerid, COLOR_RED, "You aren't an admin!");
        new
            string[128];
        if(P_Data[playerid][pDuty] == 3) {
        SetPlayerHealth(playerid,100);
        SetPlayerColor(playerid,-1);
        format(string,sizeof(string)," {FF0000} %s is now off Duty!",GetName(playerid));
        SCMToAll(-1,string); P_Data[playerid][pDuty] = 1;}
        else {
        format(string,sizeof(string)," {FF0000} %s is now on Duty!",GetName(playerid));
        SetPlayerHealth(playerid,99999);
        SetPlayerColor(playerid,0xFF000000);
        SCMToAll(-1,string); P_Data[playerid][pDuty] = 3;} // <---- This
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)