/changeclothes -
HighFlyer - 11.09.2012
Hello,
I've made a /changeclothes command, there's no errors during compilation but the command itself doesn't work in game, nothing appears when I input for instance /changeclothes 1, only the top bit of the script works. I haven't indented it yet properly, because I'm playing with it constantly.
Код:
command(changeclothes, playerid,params[])
{
new slot, string[86];
if(sscanf(params, "u", slot))
{
SendClientMessage(playerid, COLOR_WHITE, "Server: /changeclothes [slot 1-3]");
}
else
{
if(slot == 1)
{
if(Player[playerid][Clothes1] != GetPlayerSkin(playerid))
{
format(string, sizeof(string), "You have changed into your Slot 1 clothes.");
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s changed their clothes quickly. *", MaskSwitch(playerid));
SendLocalMessage(playerid, COLOR_PINK, string);
SetPlayerSkin(playerid, Player[playerid][Clothes1]);
}
else return SendClientMessage(playerid, COLOR_GREY, "You have no clothes in this slot.");
}
else if(slot == 2)
{
if(Player[playerid][Clothes2] != GetPlayerSkin(playerid))
{
format(string, sizeof(string), "You have changed into your Slot 2 clothes.");
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s changed their clothes quickly. *", MaskSwitch(playerid));
SendLocalMessage(playerid, COLOR_PINK, string);
SetPlayerSkin(playerid, Player[playerid][Clothes2]);
}
else return SendClientMessage(playerid, COLOR_GREY, "You have no clothes in this slot.");
}
else if(slot == 3)
{
if(Player[playerid][Clothes3] != GetPlayerSkin(playerid))
{
format(string, sizeof(string), "You have changed into your Slot 3 clothes.");
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "* %s changed their clothes quickly. *", MaskSwitch(playerid));
SendLocalMessage(playerid, COLOR_PINK, string);
SetPlayerSkin(playerid, Player[playerid][Clothes3]);
}
else return SendClientMessage(playerid, COLOR_GREY, "You have no clothes in this slot");
}
}
return 1;
}
Re: /changeclothes -
Dokins - 11.09.2012
This right here is your problem. The "u" is looking for a playerid, effectively.
pawn Код:
if(sscanf(params, "u", slot))
{
Change it to this ("i") is an integer.
pawn Код:
if(sscanf(params, "i", slot))
{
Need anymore help, let me know!
EDIT:
Here, this will help.
Код:
Specifier(s) Name Example values
i, d Integer 1, 42, -10
c Character a, o, *
l Logical true, false
b Binary 01001, 0b1100
h, x Hex 1A, 0x23
o Octal 045 12
n Number 42, 0b010, 0xAC, 045
f Float 0.7, -99.5
g IEEE Float 0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
u User name/id (bots and players) ******, 0
q Bot name/id ShopBot, 27
r Player name/id ******, 42
Re: /changeclothes -
HighFlyer - 11.09.2012
Thank you. I knew this, but I didn't see it, such an idiot. Such a small detail that I've missed!
However, there seems to be one issue, with Slot 1. Got a skin in the slot, but it displays the else message, any ideas?
EDIT: I have the same Skin on slots 1 and 3, and a different skin on slot 2, probably why it does that, but how can I tell it to change it anyway, regardless of the skin?
Re: /changeclothes -
Dokins - 11.09.2012
This line will not change your skin if it matches the one you currently have.
pawn Код:
if(Player[playerid][Clothes1] != GetPlayerSkin(playerid))
{
It would be more efficient if you done this:
pawn Код:
if(Player[playerid][Clothes1] != 0)
{
It means that you don't have to worry about CJ skin bugs also, cos you can't store that skin.