Why does this return Unknown command? - 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: Why does this return Unknown command? (
/showthread.php?tid=244401)
Why does this return Unknown command? -
mrcoolballs - 27.03.2011
I'm trying to make a gang system for my server, but this annoying test command won't work.
The command is suppose to be, "/getid <GangName>", which returns the ID of the gang name I enter:
pawn Код:
dcmd_getid(playerid,params[])
{
new name[40],str[128];
if(sscanf(params,"s[40]",name)) return 0;
new gangid = GetGangIDFromName(name);
format(str,sizeof(str),"The gang %s's ID is %d",GangInfo[gangid][GangName],gangid);
SendClientMessage(playerid,WHITE,str);
return 1;
}
I'm pretty sure it has something to do with the GetGangIDFromName function I created, here is the function:
pawn Код:
stock GetGangIDFromName(name[])
{
for(new i; i< MAX_GANGZ; i++)
{
if(strfind(GangInfo[i][GangName],name,false) != -1)
{
return i;
}
}
return -1;
}
Thanks
Re: Why does this return Unknown command? -
Grim_ - 27.03.2011
I fail to see why people (no, not just you) use sscanf for one parameter commands.
pawn Код:
dcmd_getid( playerid, params[ ] )
{
new str[ 128 ];
new gangid = GetGangIDFromName( params );
format( str, sizeof( str ), "The gang %s's ID is: %d", name, gangid );
SendClientMessage(playerid, WHITE, str);
return 1;
}
Re: Why does this return Unknown command? -
mrcoolballs - 27.03.2011
Probably because they don't know how. Thanks for letting me know.