SA-MP Forums Archive
[HELP] How to do /buyskin (id) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] How to do /buyskin (id) (/showthread.php?tid=161696)



[HELP] How to do /buyskin (id) - andruz99 - 20.07.2010

i need to make /buyskin (ID) and if you example typed /buyskin 21 then it sets the skin 21 how can i do like that?


Re: [HELP] How to do /buyskin (id) - bartje01 - 20.07.2010

pawn Код:
dcmd_buyskin(playerid,params[])
{
new skinid;
if(sscanf(params,"d",skinid))
{
SendClientMessage(playerid,0xFF0000FF,"Use /buyskin [skinid]");
return 1;
}
SetPlayerSkin(playerid,skinid);
GivePlayerMoney(playerid,-100);
return 1;
}
tested and works
If you want to make it free, delete the GivePlayerMoney(playerid,-100);


Re: [HELP] How to do /buyskin (id) - Lorenc_ - 20.07.2010

Quote:
Originally Posted by bartje01
Посмотреть сообщение
pawn Код:
dcmd_buyskin(playerid,params[])
{
new skinid;
if(sscanf(params,"d",skinid))
{
SendClientMessage(playerid,0xFF0000FF,"Use /buyskin [skinid]");
return 1;
}
SetPlayerSkin(playerid,skinid);
GivePlayerMoney(playerid,-100);
return 1;
}
tested and works
If you want to make it free, delete the GivePlayerMoney(playerid,-100);
Perhaps you maybe can use GetPlayerMoney so their cash dosen't go into the negatives.


Re: [HELP] How to do /buyskin (id) - bartje01 - 20.07.2010

ah yes. Wait.

EDIT:
Yes this must be it:
pawn Код:
dcmd_buyskin(playerid,params[])
{
new skinid;
if(sscanf(params,"d",skinid))
{
SendClientMessage(playerid,0xFF0000FF,"Use /buyskin [skinid]");
return 1;
}
if(GetPlayerMoney(playerid) <100)
{
SendClientMessage(playerid,0xFF0000FF,"You need atleast 100$ to use this command.");
return 1;
}
SetPlayerSkin(playerid,skinid);
GivePlayerMoney(playerid,-100);
return 1;
}
Thanks for correcting me.


Re: [HELP] How to do /buyskin (id) - andruz99 - 20.07.2010

is there a way doing it without scanf?


Re: [HELP] How to do /buyskin (id) - DJDhan - 20.07.2010

If you don't want to use sscanf, you can do that using strtok:

Код:
dcmd_buyskin(playerid,params[])
{
	new tmp[128],skinid,Index;

	if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,0xFF0000FF,"You need atleast 100$ to use this command.");

	tmp = strtok(params,Index);
	
	if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"Use /buyskin [skinid]");
	
	skinid = strval(tmp);

	SetPlayerSkin(playerid,skinid);
	GivePlayerMoney(playerid,-100);
	
	return 1;
}



Re: [HELP] How to do /buyskin (id) - Fj0rtizFredde - 20.07.2010

Or you just dont use sscanf or strtok
pawn Код:
dcmd_buyskin(playerid,params[])
{
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,0xFF0000FF,"You need atleast 100$ to use this command.");

if(isnull(params)) return SendClientMessage(playerid, 0xFF0000FF, "Use /buyskin [skinid]");

SetPlayerSkin(playerid,params);
GivePlayerMoney(playerid,-100);
return 1;
}
Something like that :P