Why does this return Unknown command?
#1

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
Reply
#2

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;
}
Reply
#3

Probably because they don't know how. Thanks for letting me know.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)