SA-MP Forums Archive
offline jail didnt work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: offline jail didnt work (/showthread.php?tid=657992)



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(playeridparams[])
{
    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD);
    new 
iPlayer40 ], iTimeiReason128 ], string164 ];
    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(sqldbiQuerysizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'"iTimeiReasoniPlayer);
        
mysql_tquery(sqldbiQuery);
        
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(playeridparams[]) 

    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD); 
    new 
iPlayer40 ], iTimeiReason128 ], string164 ]; 
    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(sqldbiQuerysizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'"iTimeiReasoniPlayer); 
        
mysql_tquery(sqldbiQuery); 

        
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(sqldbiQuerysizeof(iQuery), "SELECT `PlayerName` FROM `PlayerInfo` WHERE `PlayerName` = '%e'"playername);
    new 
Cache:result mysql_query(sqldbiQuery);
    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(playeridparams[]) 

    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD); 
    new 
iPlayer40 ], iTimeiReason128 ], string164 ]; 
    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(sqldbiQuerysizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'"iTimeiReasoniPlayer); 
        
mysql_tquery(sqldbiQuery); 

        
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(playeridparams[]) 

    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD); 
    new 
iPlayer40 ], iTimeiReason128 ], string164 ]; 
    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(sqldbiQuerysizeof(iQuery), "UPDATE `PlayerInfo` SET `Jail` = 1, `JailTime` = %d, `bail` = 777, JailReason = '%e' WHERE `PlayerName` = '%e'"iTimeiReasoniPlayer); 
        
mysql_tquery(sqldbiQuery); 
        
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