26.09.2010, 22:15
Hey guys,
I'm currently working on a new warning system which uses MySQL to store the reason for the warning. Anhow, here's the scenario... When I go ingame and type /warn [playerid] [reason] it gives them a warning but the reason doesn't save into the database.
Here's the command:
SetAccount function:
The MySQL column that holds the reason is a VARCHAR, 128 characters so I don't see what the problem is, help?
~ Mike.
I'm currently working on a new warning system which uses MySQL to store the reason for the warning. Anhow, here's the scenario... When I go ingame and type /warn [playerid] [reason] it gives them a warning but the reason doesn't save into the database.
Here's the command:
pawn Код:
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;
}
pawn Код:
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;
}
~ Mike.