Setskin command
#1

Ok. So my ID in game is 30. When I do /setskin 30 SKIN_ID it messages me, You have set James Tyson's skin to ID SKIN_ID but does not return Admin James Tyson has set your skin to SKIN_ID unless the skin_id is the same as my ID, in this case it's 30.

Код:
CMD:setskin(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
	{
	    new idx;
        new id[256];
        new tmp[512];
		id = strtok(params,idx);
		tmp = strtok(params,idx);
		SetPlayerSkin(strval(id),strval(tmp));
		new msg[256];
		new msg2[256];
		new pName[MAX_PLAYER_NAME];
		new admName[MAX_PLAYER_NAME];
    	GetPlayerName(strval(id),pName,MAX_PLAYER_NAME);
    	GetPlayerName(playerid,admName,MAX_PLAYER_NAME);
		format(msg,256,"{666666}ADMCMD:{FFFF00} You have set %s's skin to %d.", UnderscoreToSpaceName(strval(id)), strval(tmp));
		format(msg2,256,"Admin %s has set your skin to %d.", UnderscoreToSpaceName(playerid), strval(tmp));
		SendClientMessage(playerid, COLORNOTIF, msg);
		SendClientMessage(strval(tmp), COLORWHITE, msg2);
    } else return SendClientMessage(playerid, COLORERROR, "You are not authorized to use this command.");
    return 1;
}
also, how do i get it to return i.e. if i type /setskin la la it returns USAGE: /setskin <playerid> <skinid>? im using sscanf2. and can anyone explain what do numbers here: new msg[256] and other thingies similar to this mean?
Reply
#2

Are you sure you know how sscanf works and how to use it? You might want to look at a few tutorials and read up on Pawn if you're going to charge blindly into developing a script.
Reply
#3

I just got into zcmd and sscanf a few days ago. Have you got any suggestions on good tutorials? And tutorials about the "new msg[number]" that i dont really understand the numbers in it... Thank you...
Reply
#4

Код:
CMD:setskin(playerid,params[]) 
{
	new targetid, skinid, string[128];
if(!isPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not an administrator");
	if(sscanf(params,"ui",targetid, skinid)) return SendClientMessage(playerid,COLOR_WHITE,"[server]: {ffffAA} /setskin [ID | Name] [skinid]");
	else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_WHITE,"{ff0000}[Error]:{ffffff} This player is not connected.");
	{
		SetPlayerSkin(targetid, skinid);
		format(string, sizeof(string), "{ffffAA}[Admin]:{ffffff} A administrator has set your skin to %i.", skinid);
		SendClientMessage(targetid, COLOR_WHITE, string);
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by yvoms
Посмотреть сообщение
Код:
CMD:setskin(playerid,params[]) 
{
	new targetid, skinid, string[128];
if(!isPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not an administrator");
	if(sscanf(params,"ui",targetid, skinid)) return SendClientMessage(playerid,COLOR_WHITE,"[server]: {ffffAA} /setskin [ID | Name] [skinid]");
	else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_WHITE,"{ff0000}[Error]:{ffffff} This player is not connected.");
	{
		SetPlayerSkin(targetid, skinid);
		format(string, sizeof(string), "{ffffAA}[Admin]:{ffffff} A administrator has set your skin to %i.", skinid);
		SendClientMessage(targetid, COLOR_WHITE, string);
	}
	return 1;
}
I added some parts to it and it works! Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)