Command problem
#1

Hello, in this command, I've put two "if's", the first one says: if the player is NOT AOD, he becomes AOD and ..
and if the player is AOD, his AOD gets off. But when I try it in-game, the two "if's" are applied, It says in chat: "You are on duty", and in same millisecond it says: "You are off duty".
How's that?

PHP код:
CMD:aod(playeridparams[])
{
    if(
pInfo[playerid][Admin] < 1) return NotAdminMSG(playerid);
    if(
pInfo[playerid][AOD] == 0)
    {
        new 
pworld;
        
pworld GetPlayerVirtualWorld(playerid);
        
pInfo[playerid][AODLabel] = Create3DTextLabel("Admin On Duty!"COLOR_ADMIN0.0000.0000.00015.0pworld0);
        
Attach3DTextLabelToPlayer(pInfo[playerid][AODLabel], playerid0.00.00.7);
        
SetPHealth(playerid99999);
        
pInfo[playerid][AOD] = 1;
        
SCM(playeridCOLOR_WHITE""WORD_ADMIN"You are on duty now!");
        
SetPlayerColor(playeridCOLOR_ADMIN);
        return 
0;
    }
    if(
pInfo[playerid][AOD] == 1)
    {
        
SetPHealth(playerid100);
        
pInfo[playerid][AOD] = 0;
        
SCM(playeridCOLOR_WHITE""WORD_ADMIN"You are off duty now!");
        
Delete3DTextLabel(pInfo[playerid][AODLabel]);
        
CheckPlayerColor(playerid);
        return 
0;
    }
    return 
1;

Reply
#2

Код:
CMD:aod(playerid, params[]) 
{ 
    if(pInfo[playerid][Admin] < 1) return NotAdminMSG(playerid); 
    if(pInfo[playerid][AOD] == 0) 
    { 
        new pworld; 
        pworld = GetPlayerVirtualWorld(playerid); 
        pInfo[playerid][AODLabel] = Create3DTextLabel("Admin On Duty!", COLOR_ADMIN, 0.000, 0.000, 0.000, 15.0, pworld, 0); 
        Attach3DTextLabelToPlayer(pInfo[playerid][AODLabel], playerid, 0.0, 0.0, 0.7); 
        SetPHealth(playerid, 99999); 
        pInfo[playerid][AOD] = 1; 
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are on duty now!"); 
        SetPlayerColor(playerid, COLOR_ADMIN); 
    } 
    else if(pInfo[playerid][AOD] == 1) 
    { 
        SetPHealth(playerid, 100); 
        pInfo[playerid][AOD] = 0; 
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are off duty now!"); 
        Delete3DTextLabel(pInfo[playerid][AODLabel]); 
        CheckPlayerColor(playerid); 
    } 
    return 1; 
}
Reply
#3

I make this for you, but not tested xD

Код:
CMD:aod(playerid, params[])
{
    if(pInfo[playerid][Admin] < 1) return NotAdminMSG(playerid);
    if(GetPVarInt(playerid, "PlayerOnDuty"))
    {
        SetPHealth(playerid, 100);
        pInfo[playerid][AOD] = 0;
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are off duty now!");
        Delete3DTextLabel(pInfo[playerid][AODLabel]);
        CheckPlayerColor(playerid);
        return 0;
    }
    else
    {
        new pworld;
        pworld = GetPlayerVirtualWorld(playerid);
        pInfo[playerid][AODLabel] = Create3DTextLabel("Admin On Duty!", COLOR_ADMIN, 0.000, 0.000, 0.000, 15.0, pworld, 0);
        Attach3DTextLabelToPlayer(pInfo[playerid][AODLabel], playerid, 0.0, 0.0, 0.7);
        SetPHealth(playerid, 99999);
        pInfo[playerid][AOD] = 1;
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are on duty now!");
        SetPlayerColor(playerid, COLOR_ADMIN);
        SetPVarInt(playerid, "PlayerOnDuty");
        return 0;
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by lucamsx
Посмотреть сообщение
Код:
CMD:aod(playerid, params[]) 
{ 
    if(pInfo[playerid][Admin] < 1) return NotAdminMSG(playerid); 
    if(pInfo[playerid][AOD] == 0) 
    { 
        new pworld; 
        pworld = GetPlayerVirtualWorld(playerid); 
        pInfo[playerid][AODLabel] = Create3DTextLabel("Admin On Duty!", COLOR_ADMIN, 0.000, 0.000, 0.000, 15.0, pworld, 0); 
        Attach3DTextLabelToPlayer(pInfo[playerid][AODLabel], playerid, 0.0, 0.0, 0.7); 
        SetPHealth(playerid, 99999); 
        pInfo[playerid][AOD] = 1; 
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are on duty now!"); 
        SetPlayerColor(playerid, COLOR_ADMIN); 
    } 
    else if(pInfo[playerid][AOD] == 1) 
    { 
        SetPHealth(playerid, 100); 
        pInfo[playerid][AOD] = 0; 
        SCM(playerid, COLOR_WHITE, ""WORD_ADMIN"You are off duty now!"); 
        Delete3DTextLabel(pInfo[playerid][AODLabel]); 
        CheckPlayerColor(playerid); 
    } 
    return 1; 
}
Oh thanks.
SilverStand, your script (without testing) is good, but lucamsx's one is more simple.
Thanks both!
Reply
#5

You can use booleans for that too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)