offline jail didnt work -
ServerFiles - 20.08.2018
I don't know what i'm doing wrong here, im still new in mysql
when i do /ojail on someone, it appear like this
Код:
[Admin] Server_Files has jailed я for 60 minutes: test
my code:
PHP код:
COMMAND:ojail(playerid, params[])
{
if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
new iPlayer[ 40 ], iTime, iReason[ 128 ], string[ 164 ];
if( sscanf ( params, "uds", iPlayer,iTime,iReason)) return SCP(playerid, "[Exact_Name] [jailtime (MINUTES)] [reason]");
if(GetPlayerId(iPlayer) != INVALID_PLAYER_ID) return SendClientError(playerid, "That player is connected! Use /ajail!");
iTime = (iTime * 60);
if(!AccountExist(iPlayer))
{
new iQuery[228];
mysql_format(sqldb, iQuery, sizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'", iTime, iReason, iPlayer);
mysql_tquery(sqldb, iQuery);
format(string,sizeof(string),"[Admin] %s has jailed %s for %d minutes: %s",RPName(playerid),iPlayer,iTime,iReason);
SendMessageToAll(COLOR_RED,string);
}
else SendClientError(playerid, "Account not found!");
return 1;
}
Re: offline jail didnt work -
Shockey HD - 20.08.2018
Any error code in your SQL log?
Re: offline jail didnt work -
jlalt - 20.08.2018
You're passing integer parameter to sscanf and expecting a string...
PHP код:
COMMAND:ojail(playerid, params[])
{
if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
new iPlayer[ 40 ], iTime, iReason[ 128 ], string[ 164 ];
if( sscanf ( params, "s[40]ds", iPlayer,iTime,iReason)) return SCP(playerid, "[Exact_Name] [jailtime (MINUTES)] [reason]");
//if(GetPlayerId(iPlayer) != INVALID_PLAYER_ID) return SendClientError(playerid, "That player is connected! Use /ajail!");
iTime = (iTime * 60);
if(!AccountExist(iPlayer))
{
new iQuery[228];
mysql_format(sqldb, iQuery, sizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'", iTime, iReason, iPlayer);
mysql_tquery(sqldb, iQuery);
format(string,sizeof(string),"[Admin] %s has jailed %s for %d minutes: %s",RPName(playerid),iPlayer,iTime,iReason);
SendMessageToAll(COLOR_RED,string);
}
else SendClientError(playerid, "Account not found!");
return 1;
}
Re: offline jail didnt work -
ServerFiles - 20.08.2018
it returns account not found, but the account already registered.
Re: offline jail didnt work -
jlalt - 20.08.2018
show your AccountExist function?
Re: offline jail didnt work -
ServerFiles - 20.08.2018
PHP код:
stock bool:AccountExist(playername[])
{
new iQuery[128];
mysql_format(sqldb, iQuery, sizeof(iQuery), "SELECT `PlayerName` FROM `PlayerInfo` WHERE `PlayerName` = '%e'", playername);
new Cache:result = mysql_query(sqldb, iQuery);
new rows = cache_num_rows();
cache_delete(result);
if(rows > 0) return true;
return false;
}
Re: offline jail didnt work -
jlalt - 20.08.2018
Gotta use AccountExist instead of !AccountExist
PHP код:
COMMAND:ojail(playerid, params[])
{
if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
new iPlayer[ 40 ], iTime, iReason[ 128 ], string[ 164 ];
if( sscanf ( params, "s[40]ds", iPlayer,iTime,iReason)) return SCP(playerid, "[Exact_Name] [jailtime (MINUTES)] [reason]");
//if(GetPlayerId(iPlayer) != INVALID_PLAYER_ID) return SendClientError(playerid, "That player is connected! Use /ajail!");
iTime = (iTime * 60);
if(AccountExist(iPlayer))
{
new iQuery[228];
mysql_format(sqldb, iQuery, sizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'", iTime, iReason, iPlayer);
mysql_tquery(sqldb, iQuery);
format(string,sizeof(string),"[Admin] %s has jailed %s for %d minutes: %s",RPName(playerid),iPlayer,iTime,iReason);
SendMessageToAll(COLOR_RED,string);
}
else SendClientError(playerid, "Account not found!");
return 1;
}
Re: offline jail didnt work -
ServerFiles - 20.08.2018
Thanks, it's working now, but when I jailed player for 1 minute, it jailed for 60 minutes.
Re: offline jail didnt work -
jlalt - 20.08.2018
I guess you need to remove this.
PHP код:
iTime = (iTime * 60);
PHP код:
COMMAND:ojail(playerid, params[])
{
if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
new iPlayer[ 40 ], iTime, iReason[ 128 ], string[ 164 ];
if( sscanf ( params, "s[40]ds", iPlayer,iTime,iReason)) return SCP(playerid, "[Exact_Name] [jailtime (MINUTES)] [reason]");
//if(GetPlayerId(iPlayer) != INVALID_PLAYER_ID) return SendClientError(playerid, "That player is connected! Use /ajail!");
//iTime = (iTime * 60);
if(AccountExist(iPlayer))
{
new iQuery[228];
mysql_format(sqldb, iQuery, sizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'", iTime, iReason, iPlayer);
mysql_tquery(sqldb, iQuery);
format(string,sizeof(string),"[Admin] %s has jailed %s for %d minutes: %s",RPName(playerid),iPlayer,iTime,iReason);
SendMessageToAll(COLOR_RED,string);
}
else SendClientError(playerid, "Account not found!");
return 1;
}
Re: offline jail didnt work -
ServerFiles - 20.08.2018
thank you very much! everything worked fine now