if(strcmp(cmd, "/warn", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(pLogged[playerid] == 0)
{
SendSplitClientMessage(playerid, COLOR_LIGHTRED, "[ERROR]: 0003 - You've not logged in.",80,90);
return 1;
}
if(PlayerInfo[playerid][pAdmin] == 0)
{
SendSplitClientMessage(playerid, COLOR_LIGHTRED, "[ERROR]: 0004 - You're not a member of staff.",80,90);
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendSplitClientMessage(playerid, COLOR_SYSTEM, "[SYNTAX]: /warn [playerid/PartOfName] [reason]",80,90);
return 1;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendSplitClientMessage(playerid, COLOR_SYSTEM, "[SYNTAX]: /warn [playerid/PartOfName] [reason]",80,90);
return 1;
}
format(string, sizeof(string), "[ADMIN]: %s %s has just given %s a warning. (Reason: %s)",AdminRank(playerid),GPN(playerid),GPN(giveplayerid),result);
SendAdminMessage(COLOR_LIGHTRED,string);
if(giveplayerid == playerid)
{
return 1;
}
else
{
if(PlayerInfo[giveplayerid][pWarn1] == 0)
{
SetAccount(PlayerInfo[giveplayerid][pID],"warn1","1");
format(string,sizeof(string),"%s",result);
SetAccount(PlayerInfo[giveplayerid][pID],"warnreason1",string);
}
else if(PlayerInfo[giveplayerid][pWarn2] == 0)
{
SetAccount(PlayerInfo[giveplayerid][pID],"warn2","1");
format(string,sizeof(string),"%s",result);
SetAccount(PlayerInfo[giveplayerid][pID],"warnreason2",string);
}
else if(PlayerInfo[giveplayerid][pWarn3] == 0)
{
SetAccount(PlayerInfo[giveplayerid][pID],"warn3","1");
format(string,sizeof(string),"%s",result);
SetAccount(PlayerInfo[giveplayerid][pID],"warnreason3",string);
format(string,sizeof(string),"[ADMIN]: %s has been banned by server. (Reason: 3 Warnings Recieved)",GPN(giveplayerid));
SendSplitClientMessageToAll(COLOR_LIGHTRED,string,80,90);
Kick(giveplayerid);
}
}
return 1;
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendSplitClientMessage(playerid, COLOR_GRAD1, string,80,90);
}
}
return 1;
}
stock SetAccount(dbid, set[], amount[])
{
new Query[ 128 ];
format( Query, sizeof( Query ), "UPDATE players SET %s=%s WHERE id = '%d'", set,amount,dbid);
mysql_query( Query );
mysql_store_result();
mysql_free_result();
return 1;
}
I think you need to revise your second piece of code. You need to add `'s where you have "players" and "id".
|
format( Query, sizeof( Query ), "UPDATE `players` SET '%s' = '%s' WHERE `id` = '%d'", set,amount,dbid);
I'm still learning MySQL code, but look...
pawn Код:
|
Nah, you dont need it on the "players" and "id" ..
im pretty sure that the only places you need it is on the second %s and %d... |
Yeah, that's what I don't get.
As soon as I use the function with another player variable such as pSkin it works perfectly, so I haven't got any idea. ~ Mike. |