SA-MP Forums Archive
Very new to scripting please don't be too mean xD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Very new to scripting please don't be too mean xD (/showthread.php?tid=662121)



Very new to scripting please don't be too mean xD - aKnoxx - 24.12.2018

How do I send a message to the playerid saying "You have set _____'s skin to ___." in this cmd?

PHP код:
CMD:setskin(playeridparams[])
{
    new 
targetidskinid;
    if(
sscanf(params"ii"targetidskinid)) 
    return 
SendClientMessage(playerid, -1"[USAGE]: /setskin [playerid] [skinid]");
    
SetPlayerSkin(targetidskinid);
    
SendClientMessage(playerid, -1"You have set %s's skin id to %i."); //this is the line i need help with
    
return 1;




Re: Very new to scripting please don't be too mean xD - UFF - 24.12.2018

pawn Код:
CMD:setskin(playerid, params[])
{
    new targetid, skinid, str[90], name[MAX_PLAYER_NAME];
    if(sscanf(params, "ii", targetid, skinid))  
    return SendClientMessage(playerid, -1, "[USAGE]: /setskin [playerid] [skinid]");
    SetPlayerSkin(targetid, skinid);
    GetPlayerName(targetid, name, sizeof(name));
    format(str, sizeof(str), "You have set %s's skin id to %i.",name, skinid);
    SendClientMessage(playerid, -1, str);
    return 1;
}
SendClientMessage has only 3 paramaters, use format for those.


Re: Very new to scripting please don't be too mean xD - aKnoxx - 24.12.2018

tyvm, +rep


Re: Very new to scripting please don't be too mean xD - aKnoxx - 24.12.2018

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Hopefully this was helpful and you'll think more about readability as you continue to improve your programming skills!
Thank you very much! I was actually thinking about this yesterday when I was posting in this section for help, I was like... these people are definitely pissed off at how hideously compact all this code is. lmaoo

Thank you appreciate it!


Re: Very new to scripting please don't be too mean xD - TheToretto - 24.12.2018

Also:

Код:
if(sscanf(params, "ii", targetid, skinid))
use the parameter "u" instead of "i" so you can choose either the target's name or his ID, using "i" will trigger IDs only.

Код:
if(sscanf(params, "ui", targetid, skinid))



Re: Very new to scripting please don't be too mean xD - RogueDrifter - 24.12.2018

For help with parameters for functions please do refer to the wiki since it will save you and us time, link for the wiki: https://sampwiki.blast.hk/

Link for SendClientMessage function: https://sampwiki.blast.hk/wiki/SendClientMessage

Link for format function: https://sampwiki.blast.hk/wiki/format

Link for all functions: https://sampwiki.blast.hk/wiki/Category...ting_Functions
Link for all callbacks: https://sampwiki.blast.hk/wiki/Category...ting_Callbacks


Re: Very new to scripting please don't be too mean xD - aKnoxx - 24.12.2018

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Also:

Код:
if(sscanf(params, "ii", targetid, skinid))
use the parameter "u" instead of "i" so you can choose either the target's name or his ID, using "i" will trigger IDs only.

Код:
if(sscanf(params, "ui", targetid, skinid))
Thank you very much!

I was wondering how I could do this. Appreciate it. I'll try and remember to rep you tomorrow, cant give out anymore rep today lmao