20.10.2011, 10:43
Hello all,
I tried to make a sscanf parameter after the strcmp check but it didn't work
If I type /gang create, the gang name will be "create".. How to do it?
I tried to make a sscanf parameter after the strcmp check but it didn't work
pawn Код:
COMMAND:gang(playerid, params[])
{
new string[128], gName[128], Query[200], gID[5], DBResult:Result, pName[MAX_PLAYER_NAME];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, Yellow, "Usage: /gang <create>");
GetPlayerName(playerid, pName, sizeof(pName));
if (!strcmp("create", params, true))
{
if(PlayerInfo[playerid][Gang] != 0) return SendClientMessage(playerid, Red, "..");
if(sscanf(params, "s[128]", gName)) return SendClientMessage(playerid, Yellow, "Usage: /gang <create> <gangname>");
if(CheckGangByName(gName)) return SendClientMessage(playerid, Yellow, "..");
format(Query, sizeof(Query), "INSERT INTO `GANGS` (`ID`, `NAME`, `OWNER`) VALUES (NULL, '%s', '%s');", gName, pName);
db_query(Database, Query);
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s'", pName);
Result = db_query(Database, Query);
db_get_field_assoc(Result, "ID", gID, 5);
PlayerInfo[playerid][Gang] = strval(gID);
format(Query, sizeof(Query), "UPDATE `USERS` SET `GANG` = '%d' WHERE `NAME` = '%s'", PlayerInfo[playerid][Gang], pName);
db_query(Database, Query);
format(string, sizeof(string), "... Name: %s. ID: %d", gName, PlayerInfo[playerid][Gang]);
SendClientMessage(playerid, Green, string);
}
return 1;
}