SA-MP Forums Archive
SendPlayerToJail || OnPlayerDeath - 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: SendPlayerToJail || OnPlayerDeath (/showthread.php?tid=517123)



Removed - AnonScripter - 03.06.2014

Removed


Re: SendPlayerToJail || OnPlayerDeath - iThePunisher - 03.06.2014

show us the public SendPlayerToJail(playerid);


Re: SendPlayerToJail || OnPlayerDeath - rockhopper - 03.06.2014

Dont use random jails Make it only one And try


Re: SendPlayerToJail || OnPlayerDeath - AnonScripter - 03.06.2014

Quote:
Originally Posted by iThePunisher
Посмотреть сообщение
show us the public SendPlayerToJail(playerid);
i already show this.

Quote:
Originally Posted by rockhopper
Посмотреть сообщение
Dont use random jails Make it only one And try
i tried and doesn't workk.



Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
I hope you guys got my point and got what is the problem.



Re: SendPlayerToJail || OnPlayerDeath - Koala818 - 03.06.2014

I try to guess what the problem is. Let me explain.

You have under OnPlayerSpawn a function that set the player position to where it need's to be spawned. Like if he's a cop he will be spawned at the section, if he's a civilian he will be spawned at the airport etc. So OnPlayerDeath you put that player in jail, and OnPlayerSpawn you get that player out of jail. I would recommend you to make an array to save all the players that must be in jail, and OnPlayerSpawn you should put them there. Something like:
pawn Код:
new PlayerJailed[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    PlayerJailed[playerid]=0; //reset the variables for each player connected.
}

public OnPlayerSpawn(playerid)
{
    if(PlayerJailed[playerid]==1)
    {
        SendPlayerToJail(playerid);
    }
    else
    {
        //Spawn him normally
    }
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsCop[killerid] == true)
    {
        if(PlayerTeam[playerid] == TEAM_CIVILIANS && GetPlayerWantedLevel(playerid)>=4)
        {
            IncreaseScore(killerid,1);
            PlayerJailed[playerid]=1;
            return 1;
        }
    }
    return 1;
}



Re: SendPlayerToJail || OnPlayerDeath - AnonScripter - 03.06.2014

I already have this in OnPlayerSpawn. if this what causes the problem, it will make it happen in all kind of arrests.

/arrest command: works perfect
/jail command for admins: works perfect
Wanted dead by cop: works perfect
Wanted dead in car by cop after vehicle blow: PROBLEM <<<


Re: SendPlayerToJail || OnPlayerDeath - rockhopper - 03.06.2014

But as I have seen on different Server Its not necessary to Put a player in jail If he died in explosion coz it makes no sense after he dies you force him to spawn in jail again


Re: SendPlayerToJail || OnPlayerDeath - Koala818 - 03.06.2014

Huh, just what i saw. You'd want to verify if the killerid is not INVALID_PLAYER_ID. Because:
Quote:
Originally Posted by SA-MP WIKI
You MUST check whether 'killerid' is valid (not INVALID_PLAYER_ID) before using it in an array (or really anywhere), as it will cause the OnPlayerDeath script to crash (not the entire script). This is because INVALID_PLAYER_ID is defined as 65535, and if an array only has 'MAX_PLAYERS' elements, e.g. 500, you're trying to access an index that is above 499, which is out of bounds.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(IsCop[killerid] == true)
        {
            if(PlayerTeam[playerid] == TEAM_CIVILIANS && GetPlayerWantedLevel(playerid)>=4)
            {
                IncreaseScore(killerid,1);
                SendPlayerToJail(playerid);
                return 1;
            }
        }
    }
    return 1;
}
And if you say it dies by explosion, this will cause the script to bug.


Re: SendPlayerToJail || OnPlayerDeath - AnonScripter - 03.06.2014

but on deathlist it doesn't show that the killer id is invalid id,
it shows it like:
Cop Player Wanted Player


Re: SendPlayerToJail || OnPlayerDeath - AnonScripter - 03.06.2014

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Huh, just what i saw. You'd want to verify if the killerid is not INVALID_PLAYER_ID. Because:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(IsCop[killerid] == true)
        {
            if(PlayerTeam[playerid] == TEAM_CIVILIANS && GetPlayerWantedLevel(playerid)>=4)
            {
                IncreaseScore(killerid,1);
                SendPlayerToJail(playerid);
                return 1;
            }
        }
    }
    return 1;
}
And if you say it dies by explosion, this will cause the script to bug.
Thank you, Fixed rep+