sscanf -
alishvasis - 05.03.2014
How To Use Sscanf ? For enbale changeskin for Player i Mean Take skinchanger[playerid] To 1
(skinchanger[playerid] = 1
Its Code: + Rep
Код:
dcmd_givechangeskin(playerid,params[])
{
new ID;
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_RED,"use: /givechangeskin (ID)");
return 1;
}
skinchanger[playerid] = 1;
return 1;
}
Re: sscanf -
Abagail - 05.03.2014
I believe you used sscanf correctly... I couldn't understand what you meant with the skinchanger variable, though.
Re: sscanf -
Necip - 05.03.2014
With that, you are setting the command user's skinchanger to 1. Try this,
Re: sscanf -
alishvasis - 05.03.2014
Quote:
Originally Posted by Abagail
I believe you used sscanf correctly... I couldn't understand what you meant with the skinchanger variable, though.
|
I Say By This Cmd Enable skinchanger[playerid] For Player To 1.So player Can Change Skin..
Set>> For player
skinchanger[playerid] = 1;
Re: sscanf -
Necip - 05.03.2014
Quote:
Originally Posted by alishvasis
I Say By This Cmd Enable skinchanger[playerid] For Player To 1.So player Can Change Skin..
Set>> For player
skinchanger[playerid] = 1;
|
To be sure if you saw my post, check a little bit. I think it might work.
Re: sscanf -
alishvasis - 05.03.2014
Quote:
Originally Posted by Necip
To be sure if you saw my post, check a little bit. I think it might work.
|
No Its Not Work
Re: sscanf -
alishvasis - 05.03.2014
i Fixed It .any Way TnX All
Re: sscanf -
XK - 05.03.2014
It should be:
pawn Код:
dcmd_givechangeskin(playerid,params[])
{
new ID, name[MAX_PLAYER_NAME], IDname[MAX_PLAYER_NAME];
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_RED,"use: /givechangeskin (ID)");
return 1;
}
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(ID, IDname, sizeof(IDname));
skinchanger[ID] = 1;
SendClientMessage(playerid, -1, " you have gave %s the ability to change his skin. ", IDname);
SendClientMessage(ID, -1, " admin %s gave you the ability to change your skin. ", name);
return 1;
}
And to change skin:
pawn Код:
dcmd_myskin(playerid,params[])
{
new skinID;
if(sscanf(params, "i", skinID))
{
SendClientMessage(playerid,COLOR_RED,"use: /myskin (skin ID)");
return 1;
}
SendClientMessage(playerid, -1, " you have changed your skin to skin ID %s ", skinID);
SetPlayerSkin(playerid, skinID);
return 1;
}
Re: sscanf -
Konstantinos - 05.03.2014
Quote:
Originally Posted by XK
It should be:
pawn Код:
dcmd_givechangeskin(playerid,params[]) { new ID, name[MAX_PLAYER_NAME], IDname[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(ID, IDname, sizeof(IDname));
if(sscanf(params, "u", ID)) { SendClientMessage(playerid,COLOR_RED,"use: /givechangeskin (ID)"); return 1; } skinchanger[ID] = 1; SendClientMessage(playerid, -1, " you have gave %s the ability to change his skin. ", IDname); SendClientMessage(ID, -1, " admin %s gave you the ability to change your skin. ", name); return 1; }
And to change skin:
pawn Код:
dcmd_myskin(playerid,params[]) { new skinID;
if(sscanf(params, "s", skinID)) { SendClientMessage(playerid,COLOR_RED,"use: /myskin (skin ID)"); return 1; } SendClientMessage(playerid, -1, " you have changed your skin to skin ID %s ", skinID); SetPlayerSkin(playerid, skinID); return 1; }
|
Not really.
In givechangeskin:
- You get the name before the sscanf line so it always get the name of the player with ID 0.
- You don't check if the ID is a valid/connected player before using it in arrays so it can cause run time error: Array index out of bounds.
In myskin:
- The specifier should be integer (either "i" or "d") because the skinid is not a string.
Even though, he's already solved his problem.
Re: sscanf -
XK - 05.03.2014
Ah thanks for telling me i didnt notice ...And in myskin it was a missclick it shouldnt be s