PDA

View Full Version : Command to change skin


Aram555
17/01/2010, 02:48 AM
How to make the such:
When I enter a command
/skin1
varies skin on ID skin 105

Miguel
17/01/2010, 03:00 AM
public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[128], string[128], cmd[128], idx, skinid;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/changeskin", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR, "Usage: /changeskin [skinid]");
skinid = strval(tmp);
if(IsValidSkin(skinid) == 0) return SendClientMessage(playerid, COLOR, "Error: invalid skin ID!");
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, COLOR, string);
return 1;
}
return 0;
}

Copied from wiki...

Kostas'
25/09/2011, 01:15 PM
I got these errors:


C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(3741) : warning 217: loose indentation
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(3741) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(3744) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(3747) : error 017: undefined symbol "IsValidSkin"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(3753) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Should i #include <...> something for this?

dice7
25/09/2011, 01:30 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/changeskin", true, 11) == 0)
{
new string[128], skinid;
if(!cmdtext[11]) return SendClientMessage(playerid, COLOR, "Usage: /changeskin [skinid]");
skinid = strval(cmdtext[12]);
switch(skinid)
{
case 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289: { return SendClientMessage(playerid, COLOR, "Error: invalid skin ID!"); }
default:
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, COLOR, string);
}
}
return 1;
}
return 0;
}

Kostas'
25/09/2011, 03:08 PM
It's compile and the command works, but i have a warning

MA_proking
25/09/2011, 04:53 PM
if(strcmp(cmd, "/myskin", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, red, "Usage: /myskin [skinid]");
return 1;
}
new skin;
skin = strval(tmp);
format(string, sizeof(string), "You change your skin to this skin ID: %d", skin);
SendClientMessage(playerid, COLOR_GREEN, string);
SetPlayerSkin(playerid, skin);
return 1;
}

This will work

Kostas'
25/09/2011, 06:27 PM
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4329) : error 017: undefined symbol "cmd"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4331) : error 017: undefined symbol "tmp"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4331) : error 017: undefined symbol "idx"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4332) : error 017: undefined symbol "tmp"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4334) : error 017: undefined symbol "red"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4338) : error 017: undefined symbol "tmp"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4339) : error 017: undefined symbol "string"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4339) : error 017: undefined symbol "string"
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4339) : error 029: invalid expression, assumed zero
C:\Documents and Settings\orion\Τα έγγραφά μου\Τα έγγραφά μου\XtreameGaming Gamemode\gamemodes\Xtreamgaming.pwn(4339) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


10 Errors.

I must add something?

Kingunit
25/09/2011, 06:37 PM
This one need zcmd and sscanf:

CMD:setskin(playerid, params[])
{
new level, id;
if(sscanf(params, "dd", id, level)) return SendClientMessage(playerid, WHITE, "{FF0000}USAGE:{FFFFFF} /setskin [playerid] [skin id]");
{
if(level > 299 || level < 1) return SendClientMessage(playerid, GREY, "Invalid skin ID!");
SetPlayerSkin(id, level);
}
return 1;
}

Kostas'
25/09/2011, 07:12 PM
Thank you, Kingunit!
It works fine!

SantarioLeone
26/09/2011, 01:31 AM
Right as LAs Venturas CNR said it doesnt detect invalid IDS and if someone set your skin as an invalid ID you'll crash. Try my ZCMD and sscanf setskin cmd
Also this works only for admins whos level is 4 but you can change that value to whatever you desire.
CMD:setskin(playerid, params[])
{
new id, ammount, name[MAX_PLAYER_NAME], string[128];
if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SendClientMessage(playerid, COLOR_GREY,"You are not authorized to use this command");
else if(sscanf(params,"ui", id, ammount)) return SendClientMessage(playerid, COLOR_GREY,"[True:RP]: /setskin [playerid/partofname] [skinmodel]");
else if(ammount > 299 || ammount < 1) return SendClientMessage(playerid, COLOR_GREY,"Wrong Skin ID! Available ID's: 1-299");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREY,"Invalid player id");
else
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"Your skin have been set to %i by admin %s", ammount, name);
SendClientMessage(id, COLOR_GREEN, string);
PlayerInfo[id][pSkin] = ammount;
SetPlayerSkin(id, PlayerInfo[id][pSkin]);
}
return 1;
}

Kingunit
26/09/2011, 06:24 AM
I am checking it, kinda blind ...

if(level > 299 || level < 1) return SendClientMessage(playerid, GREY, "Invalid skin ID!");


Please read better before dropping a comment about me.

Wyasabi
29/06/2012, 02:50 PM
I'm Using that :



if(strcmp(cmdtext, "/changeskin", true, 11) == 0)
{
new string[128], skinid;
if(!cmdtext[11]) return SendClientMessage(playerid, 0xFFFF00AA, "Usage: /changeskin [skinid]");
skinid = strval(cmdtext[12]);
switch(skinid)
{
case 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289: { return SendClientMessage(playerid, 0xFFFF00AA, "Error: invalid skin ID!"); }
default:
{
SetPlayerSkin(playerid, skinid);
format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
SendClientMessage(playerid, 0xFFFF00AA, string);
}
}
return 1;

and i have 1 warn ;(

pawn Code:C:\Documents and Settings\Krasi\Desktop\My Drift Server\gamemodes\elitedrift.pwn(1460) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.

Please help me :(