Setlevel mysql
#1

Hello guys! I have a problem.
Why it don't works? Please help.
code:
CMD:
Код:
CMD:setlevel(playerid, params[])
{
   if(!IsPlayerAdmin(playerid)) return true;
   new mysql_query[128];
   if(sscanf(params,"dd", params[0], params[1])) return SendClientMessage(playerid, COLOR_YELLOW, "use: /setlevel [account id] [level]");
   if(IsPlayerConnected(GetPlayerID(params[0])))
   {
      PlayerInfo[params[0]][pAdminLevel] = params[1];
   }
   else if(!IsPlayerConnected(GetPlayerID(params[0])))
   {
      	format(mysql_query, sizeof(mysql_query), "UPDATE `accounts` SET `pAdmin` = '%d' WHERE `id` = '%d'",params[1], params[0]);
	  	mysql_function_query(connects, mysql_query, false, "", "");
   }
   SendClientMessage(playerid, COLOR_YELLOW, "bla-bla-bla");
   return true;
}
GetPlayerID:
Код:
stock GetPlayerID(string[])
{
	foreach(Player,i)
	{
		if(IsPlayerConnected(i) == 1)
		{
			if(strcmp(PlayerInfo[i][pNickName], string, true, strlen(string)) == 0) { return i; }
		}
	}
	return INVALID_PLAYER_ID;
}
Reply
#2

any errors?
and I'm not sure this kind of using "params" will work, try using sscanf
Reply
#3

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
any errors?
and I'm not sure this kind of using "params" will work, try using sscanf
no any erros / warning... but code don't works. i don't know why
Reply
#4

well I think its GetPlayerID problem, because you check for id with name, but you provide SQL ID in function
Reply
#5

try this

pawn Код:
CMD:setlevel(playerid, params[])
{
   if(!IsPlayerAdmin(playerid)) return true;
   new mysql_query[128], lookupid, level;
   if(sscanf(params,"ui",lookupid ,level)) return SendClientMessage(playerid, COLOR_YELLOW, "use: /setlevel [PlayerName/ID] [level]");
   if(!IsPlayerConnected(GetPlayerID(lookupid))) return SendClientMessage(playerid, -1, "that player is not connected");

   PlayerInfo[lookupid][pAdminLevel] = level;
   format(mysql_query, sizeof(mysql_query), "UPDATE `accounts` SET `pAdmin` = '%d' WHERE `id` = '%d'",level, GetPlayerID(lookupid));
   mysql_function_query(connects, mysql_query, false, "", "");
   return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)