offline jail didnt work
#1

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;

Reply
#2

Any error code in your SQL log?
Reply
#3

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

Reply
#4

it returns account not found, but the account already registered.
Reply
#5

show your AccountExist function?
Reply
#6

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;

Reply
#7

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

Reply
#8

Thanks, it's working now, but when I jailed player for 1 minute, it jailed for 60 minutes.
Reply
#9

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

Reply
#10

thank you very much! everything worked fine now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)