sscanf
#1

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;
}
Reply
#2

I believe you used sscanf correctly... I couldn't understand what you meant with the skinchanger variable, though.
Reply
#3

With that, you are setting the command user's skinchanger to 1. Try this,
pawn Код:
skinchanger[ID] = 1;
Reply
#4

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;
Reply
#5

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.
Reply
#6

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
Reply
#7

i Fixed It .any Way TnX All
Reply
#8

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;
}
Reply
#9

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.
Reply
#10

Ah thanks for telling me i didnt notice ...And in myskin it was a missclick it shouldnt be s
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)