Dcmd question. - 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: Dcmd question. (
/showthread.php?tid=157348)
Dcmd question. -
oliverrud - 06.07.2010
Hey, I'm trying to make like a command for example: /v [name] in dcmd.
Actually what I'm making is a /creategun [gunname] command, however I can't seem to get it working.
pawn Code:
dcmd_creategun(playerid, params[])
{
new id[64];
if(sscanf(params,"s",id))
{
SendClientMessage(playerid,COLOR_YELLOW,"Usage: /creategun [GunName]");
SendClientMessage(playerid,COLOR_YELLOW,"Deagle[3], Shotgun[1]");
SendClientMessage(playerid,COLOR_YELLOW,"MP5[4], Sniper[7]");
}
else
{
if(sscanf(params,"deagle",id))
{
if(PlayerAccount[playerid][WeaponPackages] >= 3)
{
GivePlayerWeapon(playerid,24,100);
PlayerAccount[playerid][WeaponPackages] -= 3;
}
else
{
SendClientMessage(playerid,COLOR_YELLOW,"Not Enough Weapon Packages");
}
}
}
I guess I'm doing something wrong at this:
pawn Code:
if(sscanf(params,"deagle",id))
Re: Dcmd question. -
Betamaster - 06.07.2010
If your only ever expecting a single string input from the command, get rid of the sscanf altogether.
Remove your id variable.
Replace if(sscanf(params,"s",id)) with a param null check.
Replace if(sscanf(params,"deagle",id)) with a simple strcmp check.
Re: Dcmd question. -
oliverrud - 06.07.2010
Mhm okay, I don't really get what you mean by Replace if(sscanf(params,"deagle",id)) with a simple strcmp check.
Like:
pawn Code:
if(strcmp(params,"deagle"))
It gives a error so I guess it's not like that, could you maybe help me a little more, I would be very grateful, thanks.
Re: Dcmd question. -
Betamaster - 06.07.2010
Well you could do something like this:
pawn Code:
stock equal(string[], compare[], bool:ignorecase = true) {
if(strlen(string) == strlen(compare) && strcmp(string, compare, ignorecase) == 0) return true;
return false;
}
if(equal(params,"deagle"))
Re: Dcmd question. -
oliverrud - 06.07.2010
Working now

Thanks!