Setting skin after use of command
#1

Hello, i've been working on a duty command, where when the admin goes on duty it changes their skin, but I am having trouble putting the skin back to what it was, could you have a look at it please, thank you.
pawn Код:
new Duty[MAX_PLAYER_NAME];
CMD:duty(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return 0;
    new Type[12];
    new Float:health, Float:skin;
    GetPlayerSkin(playerid, skin);
    GetPlayerHealth(playerid, health);
    if(sscanf(params, "u[50]", ID, Type)) return SCM(playerid, orange, "Go on duty: /duty <on/off>");
    if(strcmp(Type, "on", true) == 0)
    {
        Duty[playerid] = 1;
        GetPlayerName(playerid, pName, sizeof(pName));
        format(ustr, sizeof(ustr), "%s %s is ON duty.", AdminLevelName(playerid), pName);
        SendMessageToAdmins(Lblue, ustr);
        SetPlayerSkin(playerid, 217);
        SetPlayerHealth(playerid, 100000000);
    }

    else if(strcmp(Type, "off", true) == 0)
    {
        Duty[playerid] = 0;
        GetPlayerName(playerid, pName, sizeof(pName));
        format(ustr, sizeof(ustr), "%s %s is OFF duty.", AdminLevelName(playerid), pName);
        SendMessageToAdmins(Lblue, ustr);
        SetPlayerHealth(playerid, health);
        SetPlayerSkin(playerid, skin);
       
    }
    return 1;
}
Thanks again! oh and if you have any tips to help me improve the command, please say so!
Reply
#2

You'll figure it out:

pawn Код:
new LastSkin[MAX_PLAYERS];
pawn Код:
LastSkin[playerid] = GetPlayerSkin(playerid);
pawn Код:
SetPlayerSkin(playerid, LastSkin[playerid]);
Reply
#3

I'd recommend actually storing the skin in the administrator's stats(assuming the OnDuty status saves), this way their oldskin won't be lost after logging off. @Schneider
Reply
#4

Thanks for the reply, but now I've tried it, I've found another problem, when I do /duty off, it thinks I'm writing On... so it keeps staying on as it thinks i'm still on duty, know where i've gone wrong with the code?
pawn Код:
new Duty[MAX_PLAYER_NAME];
CMD:duty(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return 0;
    new Type[12];
    new LastSkin[MAX_PLAYER_NAME];
    LastSkin[playerid] = GetPlayerSkin(playerid);
    new Float:health;
    GetPlayerHealth(playerid, health);
    if(sscanf(params, "u[50]", ID, Type)) return SCM(playerid, orange, "Go on duty: /duty <on/off>");
    if(strcmp(Type, "on", true) == 0)
    {
        Duty[playerid] = 1;
        GetPlayerName(playerid, pName, sizeof(pName));
        format(ustr, sizeof(ustr), "%s %s is ON duty.", AdminLevelName(playerid), pName);
        SendMessageToAdmins(Lblue, ustr);
        SetPlayerSkin(playerid, 217);
        SetPlayerHealth(playerid, 100000000);
    }

    else if(strcmp(Type, "off", true) == 0)
    {
        Duty[playerid] = 0;
        GetPlayerName(playerid, pName, sizeof(pName));
        format(ustr, sizeof(ustr), "%s %s is OFF duty.", AdminLevelName(playerid), pName);
        SendMessageToAdmins(Lblue, ustr);
        SetPlayerHealth(playerid, health);
        SetPlayerSkin(playerid, LastSkin[playerid]);
       
    }
    return 1;
}
Quote:

I'd recommend actually storing the skin in the administrator's stats(assuming the OnDuty status saves), this way their oldskin won't be lost after logging off. @Schneider

Didn't see your message :S hmm I wasn't thinking of saving anything, but it would be a good idea, so I could remove the weapons so when they go on duty they lose their weapons intill they come back off, good thinking, thanks
Reply
#5

if(sscanf(params, "us", ID, Type)) ( you forgot the "s" )

Also if(strcmp(Type, "on", true) == 0)
change to :
Код:
if(!strcmp(Type, "on", false))
and the off one to :
Код:
if(!strcmp(Type, "off", false))
Little edit : SetPlayerHealth(playerid, 100000000); change to : SetPlayerHealth(playerid, 0x7F800000); because 1000000000000000000000 isn't gonna save you from fall damage.
Reply
#6

Okay, thanks for the help, I will test it when I am at home, thanks for the health tip as well!
Reply
#7

Quote:

if(sscanf(params, "us[5]", ID, Type))

Dont forget the string size.
Reply
#8

Hmm, I changed
Код:
if(sscanf(params, "u[50]", ID, Type)) return SCM(playerid, orange, "Go on duty: /duty <on/off>");
to
Код:
if(sscanf(params, "us[50]", ID, Type)) return SCM(playerid, orange, "Go on duty: /duty <on/off>");
and put
Код:
false))
like you said, but now when I do /duty on, the sscanf message just keeps appearing..
Reply
#9

Do you even know what false/true does?
Quote:
Originally Posted by Wiki
ignorecase (optional) When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same.
And also, you defined "us[50]" in sscanf, although your Type array is defined as 12.
As i showed you in my post, you only need a size of 5 anyways, the strcmp comparisons aren't longer than 5 characters.
Reply
#10

Код:
new Duty[MAX_PLAYER_NAME];
CMD:duty(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1)return 0;
    new Type[5];
    new LastSkin[MAX_PLAYER_NAME];
    LastSkin[playerid] = GetPlayerSkin(playerid);
    new Float:health;
	GetPlayerHealth(playerid, health);
    if(sscanf(params, "s[5]", Type)) return SCM(playerid, orange, "Go on duty: /duty <on/off>"); 
    if(!strcmp(Type, "on", false))
    {
		Duty[playerid] = 1;
		GetPlayerName(playerid, pName, sizeof(pName));
		format(ustr, sizeof(ustr), "%s %s is ON duty.", AdminLevelName(playerid), pName);
    	SendMessageToAdmins(Lblue, ustr);
		SetPlayerSkin(playerid, 217);
		SetPlayerHealth(playerid, 100000000);
    }

    else if(!strcmp(Type, "off", false))
    {
        Duty[playerid] = 0;
		GetPlayerName(playerid, pName, sizeof(pName));
		format(ustr, sizeof(ustr), "%s %s is OFF duty.", AdminLevelName(playerid), pName);
    	SendMessageToAdmins(Lblue, ustr);
    	SetPlayerHealth(playerid, health);
    	SetPlayerSkin(playerid, LastSkin[playerid]);
    	
    }
	return 1;
}
Good luck with your command :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)