Jail Bug
#1

Hello i have Problйm in Jail system When i die he spawn again and When he disconnect like when he die.
i want when he die he back to Jail and When he Disconnect and back he back to Jail Again help me.
PHP код:
new JailTimer[MAX_PLAYERS];// for the timer
enum
{
    
Jailed,
}
OnPlayerconnect
    PlayerInfo
[playerid][Jailed] = 0;
OnPlayerspawn
    
if (PlayerInfo[playerid][Jailed] == 1)
    {
        
SetPlayerInterior(playerid,6);
        
SetPlayerPos(playerid,264.1542,77.6009,1001.0391);
    }
OnPlayerDeath
    
if (PlayerInfo[playerid][Jailed] == 1)
    {
          
SetPlayerInterior(playerid,6);
          
SetPlayerPos(playerid,264.1542,77.6009,1001.0391);
    }
CMD:jail(playerid,params[])
{
    if (
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!");
    new 
id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME],szString[128];
    if(
sscanf(params,"dds",id,time,reason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /jail <playerid> <time> <reason>");
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected.");
    if(
PlayerInfo[id][Jailed] == 1) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is already jailed.");
    
GetPlayerName(idPlayerNamesizeof(PlayerName));
    
GetPlayerName(playeridGPlayerNamesizeof(GPlayerName));
    
format(szStringsizeof(szString), "Admin %s(%d) has  jailed you for %d minutes; Reason: %s"GetPlayerNameEx(playerid), idtimereason);
    
SendClientMessage(id,0x00D9ADFFszString);
    
SetPlayerInterior(id6);
    
SetPlayerVirtualWorld(id10);
    
SetPlayerPos(id264.1542,77.6009,1001.0391);
    
ResetPlayerWeapons(id);
    
JailTimer[id] = SetTimerEx("Unjail",time*60000false"i"id);
    return 
1;
}
CMD:unjail(playerid,params[])
{
         new 
id;
         if (
PlayerInfo[playerid][Admin] < 3) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!");
        if(
sscanf(params,"u",id)) return SendClientMessage(playeridCOLOR_RED"USAGE: /unjail <playerid>");//sscanf routine
        
if (!IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected.");//checks if the targetid is connected
        
PlayerInfo[id][Jailed] = 0;// sets his jail to 0 = unjailed
        
SetPlayerInterior(id0);//normal int
        
SetPlayerVirtualWorld(id0);//normal vw
        
SpawnPlayer(id);//respawns player
        
SetPlayerHealth(id100);//sets his health back as 100
        
KillTimer(JailTimer[id]);//kills the timer
        
return 1;

Reply
#2

In
Код:
public OnPlayerDeath
add:
Код:
if (PlayerInfo[playerid][Jailed] == 1)
    {
        SetPlayerInterior(playerid,6);
        SetPlayerPos(playerid,264.1542,77.6009,1001.0391);
    }
Reply
#3

Quote:
Originally Posted by 3MY
Посмотреть сообщение
In
Код:
public OnPlayerDeath
add:
Код:
if (PlayerInfo[playerid][Jailed] == 1)
    {
        SetPlayerInterior(playerid,6);
        SetPlayerPos(playerid,264.1542,77.6009,1001.0391);
    }
No, that will just teleport the dead body to the jail. This should be done OnPlayerSpawn...

OT: You should first save and load the variable then you can move on with spawning him back there if he relogs
Reply
#4

Quote:
Originally Posted by 3MY
Посмотреть сообщение
In
Код:
public OnPlayerDeath
add:
Код:
if (PlayerInfo[playerid][Jailed] == 1)
    {
        SetPlayerInterior(playerid,6);
        SetPlayerPos(playerid,264.1542,77.6009,1001.0391);
    }
Ready man u can't see?
Reply
#5

Quote:
Originally Posted by Sellize
Посмотреть сообщение
No, that will just teleport the dead body to the jail. This should be done OnPlayerSpawn...

OT: You should first save and load the variable then you can move on with spawning him back there if he relogs
What U Mean Bro?
Reply
#6

PHP код:
CMD:jail(playerid,params[]) 

    if (
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!"); 
    new 
id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME],szString[128]; 
    if(
sscanf(params,"dds",id,time,reason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /jail <playerid> <time> <reason>"); 
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected."); 
    if(
PlayerInfo[id][Jailed] == 1) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is already jailed."); 
    
GetPlayerName(idPlayerNamesizeof(PlayerName)); 
    
GetPlayerName(playeridGPlayerNamesizeof(GPlayerName)); 
    
format(szStringsizeof(szString), "Admin %s(%d) has  jailed you for %d minutes; Reason: %s"GetPlayerNameEx(playerid), idtimereason); 
    
SendClientMessage(id,0x00D9ADFFszString); 
    
SetPlayerInterior(id6); 
    
SetPlayerVirtualWorld(id10); 
    
SetPlayerPos(id264.1542,77.6009,1001.0391); 
    
ResetPlayerWeapons(id); 
    
JailTimer[id] = SetTimerEx("Unjail",time*60000false"i"id); 
    return 
1

In your script, the variable is not 1, so it's not working as well, change it to :

PHP код:
CMD:jail(playerid,params[]) 

    if (
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!"); 
    new 
id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME],szString[128]; 
    if(
sscanf(params,"dds",id,time,reason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /jail <playerid> <time> <reason>"); 
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected."); 
    if(
PlayerInfo[id][Jailed] == 1) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is already jailed."); 
    
GetPlayerName(idPlayerNamesizeof(PlayerName)); 
    
GetPlayerName(playeridGPlayerNamesizeof(GPlayerName)); 
    
format(szStringsizeof(szString), "Admin %s(%d) has  jailed you for %d minutes; Reason: %s"GetPlayerNameEx(playerid), idtimereason); 
    
SendClientMessage(id,0x00D9ADFFszString); 
    
SetPlayerInterior(id6); 
    
SetPlayerVirtualWorld(id10); 
    
SetPlayerPos(id264.1542,77.6009,1001.0391); 
    
PlayerInfo[playerid][Jailed] = 1//The variable is called
    
ResetPlayerWeapons(id); 
    
JailTimer[id] = SetTimerEx("Unjail",time*60000false"i"id); 
    return 
1

Reply
#7

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
PHP код:
CMD:jail(playerid,params[]) 

    if (
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!"); 
    new 
id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME],szString[128]; 
    if(
sscanf(params,"dds",id,time,reason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /jail <playerid> <time> <reason>"); 
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected."); 
    if(
PlayerInfo[id][Jailed] == 1) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is already jailed."); 
    
GetPlayerName(idPlayerNamesizeof(PlayerName)); 
    
GetPlayerName(playeridGPlayerNamesizeof(GPlayerName)); 
    
format(szStringsizeof(szString), "Admin %s(%d) has  jailed you for %d minutes; Reason: %s"GetPlayerNameEx(playerid), idtimereason); 
    
SendClientMessage(id,0x00D9ADFFszString); 
    
SetPlayerInterior(id6); 
    
SetPlayerVirtualWorld(id10); 
    
SetPlayerPos(id264.1542,77.6009,1001.0391); 
    
ResetPlayerWeapons(id); 
    
JailTimer[id] = SetTimerEx("Unjail",time*60000false"i"id); 
    return 
1

In your script, the variable is not 1, so it's not working as well, change it to :

PHP код:
CMD:jail(playerid,params[]) 

    if (
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You are not authorized to use this command!"); 
    new 
id,time,reason[100],PlayerName[MAX_PLAYER_NAME],GPlayerName[MAX_PLAYER_NAME],szString[128]; 
    if(
sscanf(params,"dds",id,time,reason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /jail <playerid> <time> <reason>"); 
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected."); 
    if(
PlayerInfo[id][Jailed] == 1) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is already jailed."); 
    
GetPlayerName(idPlayerNamesizeof(PlayerName)); 
    
GetPlayerName(playeridGPlayerNamesizeof(GPlayerName)); 
    
format(szStringsizeof(szString), "Admin %s(%d) has  jailed you for %d minutes; Reason: %s"GetPlayerNameEx(playerid), idtimereason); 
    
SendClientMessage(id,0x00D9ADFFszString); 
    
SetPlayerInterior(id6); 
    
SetPlayerVirtualWorld(id10); 
    
SetPlayerPos(id264.1542,77.6009,1001.0391); 
    
PlayerInfo[playerid][Jailed] = 1//The variable is called
    
ResetPlayerWeapons(id); 
    
JailTimer[id] = SetTimerEx("Unjail",time*60000false"i"id); 
    return 
1

Work when Player die in jail he come back but im trying now for Plaer Left server and back must go jail if he was Jailed +rep and Ty
Reply
#8

Make a variable of JailTime in your "OnPlayerDisconnect" and in your database.
If the player disconnect while in jail, it's called in the DB.
Reply
#9

Fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)