SendPlayerToJail || OnPlayerDeath
#1

Removed
Reply
#2

show us the public SendPlayerToJail(playerid);
Reply
#3

Dont use random jails Make it only one And try
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

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 <<<
Reply
#7

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
Reply
#8

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.
Reply
#9

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

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+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)