if(strcmp(cmd, "/ban", true) == 0)
{
if (PlayerInfo[playerid][Administrator] >= 3)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /ban [playerid/nume jucator] [motiv] {FFFFFF}))");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid == playerid) { SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie - {C0C0C0}aceasta comanda trebuie executata pe alta persoana {FFFFFF}))"); return 1; }
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
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))
{
SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /ban [playerid/nume jucator] [motiv] {FFFFFF}))");
return 1;
}
new Year, Month, Day;
getdate(Year, Month, Day);
new stringdata[456];
format(stringdata, sizeof(stringdata), "%02d/%02d/%02d", Day,Month,Year);
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
new stringora[456];
format(stringora, sizeof(stringora), "%02d:%02d", Hour,Minute);
new stringmotiv[456];
format(stringmotiv, sizeof(stringmotiv), "%s", (result));
format( szQuery, 500, "INSERT INTO `bans` (Data,Ora,Echipa,Jucator,Motiv) VALUES ('%s','%s','%s','%s','%s')", stringdata,stringora,stringmotiv,GetName(playerid),giveplayer);
mysql_tquery( SQL, szQuery, "", "" );
new string[456];
format(string, sizeof(string), "{CC0033}(Anunt) {CC0033}Jucatorul %s a fost banat de catre administratorul %s (%s)", giveplayer,GetName(playerid), (result));
SendClientMessageToAllEx(COLOR_GRAD1,string);
format(string, sizeof(string),"{FFFFFF}- Jucator , din pacate ai primit {FF0033}ban{FFFFFF} de la administratorul %s!\n\n{FFF1AF}[Administratorul ti-a banat contul motivul pentru care ai fost banat in joc este %s !]",GetName(playerid),(result));
ShowPlayerDialog(giveplayerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, " ", string, "Bine", "");
new name[MAX_PLAYER_NAME+1], query8[450];
GetPlayerName(giveplayerid, name, sizeof(name));
PlayerInfo[giveplayerid][Banned] = 1;
format(query8, sizeof(query8),"UPDATE `Accounts` SET `Banned` = 1, `BannedM` = '%s' WHERE `Name` = '%s'", (result), name);
mysql_tquery( SQL , query8 , "" , "" );
SetTimerEx("KickTimer", 1000, 0, "d", giveplayerid);
return 1;
}
}
else
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new tmp2[64];
while ((idx < length) && ((idx - offset) < (sizeof(tmp2) - 1)))
{
tmp2[idx - offset] = cmdtext[idx];
idx++;
}
tmp2[idx - offset] = EOS;
if(!strlen(tmp2))
{
SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /ban [playerid/nume jucator] [motiv] {FFFFFF}))");
return 1;
}
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /ban [playerid/nume jucator] [motiv] {FFFFFF}))");
return 1;
}
new Destinatar[256];
format(Destinatar, 50, "%s", (tmp2));
new Motiv[256];
format(Motiv, 256, "%s", (result));
format( szQuery, 500, "SELECT * FROM `Accounts` WHERE `Name` = '%s' LIMIT 1;", Destinatar );
new Get[ 2 ], query8[256];
cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
if( !Get[ 0 ] )
{
SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} acest jucator nu a fost gasit in baza de date! {FFFFFF}))");
return 1;
}
format(query8, sizeof(query8),"UPDATE `Accounts` SET `Banned` = 1, `BannedM` = '%s' WHERE `Name` = '%s'", Motiv,Destinatar);
mysql_tquery( SQL , query8 , "" , "" );
new string[456];
format(string, sizeof(string), "{CC0033}(Anunt) {CC0033}Jucatorul %s a fost banat-offline de catre administratorul %s (%s)", Destinatar, GetName(playerid),Motiv);
SendClientMessageToAllEx(COLOR_GRAD1,string);
new Year, Month, Day;
getdate(Year, Month, Day);
new stringdata[456];
format(stringdata, sizeof(stringdata), "%02d/%02d/%02d", Day,Month,Year);
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
new stringora[456];
format(stringora, sizeof(stringora), "%02d:%02d", Hour,Minute);
new stringmotiv[456];
format(stringmotiv, sizeof(stringmotiv), "%s", (result));
format( szQuery, 500, "INSERT INTO `bans` (Data,Ora,Echipa,Jucator,Motiv) VALUES ('%s','%s','%s','%s','%s')", stringdata,stringora,stringmotiv,GetName(playerid),giveplayerid);
mysql_tquery( SQL, szQuery, "", "" );
}
}
else
{
SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} nu ai accces la aceasta comanda! {FFFFFF}))");
}
return 1;
}
mysql_tquery
Why some people still swear by using this outdated code, including several copies of strtok, is far beyond me. Use a modern command processor. Use sscanf. Use threaded queries! Honestly, why do I still bother?
As far as the problem concerns, I see a query being formatted but it isn't actually sent to the server. |