can anyone script me a /skin command?
#1

make it like anyone can use it(NO ZCMD PLEASE)
Reply
#2



At least follow your own signature status and try to learn then. Here you go, since you capsed all in to not use ZCMD, happy holidays!

Код:
CMD:setskin(playerid, params[])
{
	new targetid, skinid;
	if (sscanf(params, "ui", targetid, skinid))
	{
		return SendClientMessage(playerid, 0xFF0000FF, "/setskin");
	}
	SetPlayerSkin(targetid, skinid);
	SendClientMessage(playerid, 0xFFFFFFFF, "You have set someone's skin to something... yay.");
	return 1;
}
Remember to restrict it to the skin id's as well so players can't input more or lower than the allowed skin ID (https://sampwiki.blast.hk/wiki/Skins:All).
Reply
#3

Making a command like this without a command processor is a bad idea as you will need to use OnPlayerCommandText (it's slow) and strtok (or you could use strmid if you know the length of the command).
Reply
#4

Zcmd would be easier than strcmp
Reply
#5

Quote:
Originally Posted by RyderX
Посмотреть сообщение
Zcmd would be easier than strcmp
Only because people use strtok, tmp, idx and all that, using sscanf will make it the same.
Reply
#6

Код:
CMD:skin(playerid, params[]) return SetPlayerSkin(playerid, strval(params));
Enjoy.
Reply
#7

strcmp :

PHP код:
new idx;
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (!
strcmp("/skin"cmdtexttrue) == 0)
    {
        new 
tmp[256], str[75];
        
tmp strtok (cmdtextidx);
        if (!
strlen(tmp)  return  SendClientMessage(playerid, -1"USAGE: /skin [Skin Id]");
        
SetPlayerSkin(playeridstrval(tmp));
        
format(strsizeof(str), "You have changed your skin to Id : %s"GetPlayerSkin(playerid));
        
SendClientMessage(playerid, -1str);
        return 
1;
    }
    return 
0;

ZCMD / IZCMD / Pawn:CMD
PHP код:
CMD:skin(playeridparams[])
{
        new 
str[75];
        if (
isnull(params)  return  SendClientMessage(playerid, -1"USAGE: /skin [Skin Id]");
        
SetPlayerSkin(playeridparams);
        
format(strsizeof(str), "You have changed your skin to Id : %s" ,params);
        
SendClientMessage(playerid, -1str);
        return 
1;

choose what you want

take care
Reply
#8

ZCMD & Sscanf2 Ways :

PHP код:
CMD:skin(playerid,params[])
{
        new 
skin;
        if(
sscanf(params,"i",skin)) return SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}Usage: /skin (skinid)");
        if(!
IsValidSkin(skin)) return SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}Invalid skinID");
        
SetPlayerSkin(playerid,skin);
        
SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}You've chosen your Custom Skin.");
        return 
1;
}
stock IsValidSkin(SkinID)
{
    if((
SkinID >= && SkinID <= 2)||(SkinID == 7)||(SkinID >= && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) return true;
    else return 
false;

Reply
#9

Quote:
Originally Posted by RyderX
Посмотреть сообщение
ZCMD & Sscanf2 Ways :

PHP код:
CMD:skin(playerid,params[])
{
        new 
skin;
        if(
sscanf(params,"i",skin)) return SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}Usage: /skin (skinid)");
        if(!
IsValidSkin(skin)) return SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}Invalid skinID");
        
SetPlayerSkin(playerid,skin);
        
SendClientMessage(playerid,0xF8F8F8FFF,"[SERVER]: {FFFFFF}You've chosen your Custom Skin.");
        return 
1;
}
stock IsValidSkin(SkinID)
{
    if((
SkinID >= && SkinID <= 2)||(SkinID == 7)||(SkinID >= && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) return true;
    else return 
false;

First of all you don't need the stock keyword there, second you can simply do
Код:
if (skinid >= 0 && skinid <= 311)
and third you can simply use strval instead of sscanf.
Reply
#10

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Код:
if (skinid >= 0 && skinid <= 311)
No, 74 isn't a valid skin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)