OnPlayerDeath
#1

Hello,
I'm working on a Counter Strike Gamemode.
Well, I'm a little bit confused.
I'm spawning the player, on OnplayerDeath.
But it still Returns to ClassSelection.

Anybody can help me out?

this is the OnPlayerDeath Public.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    if(PlayerInfo[playerid][pTeam] == 1)
    {
    SetSpawnInfo( playerid, 0, 294, 195.5586,427.2332,12.7379,93.6763, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
    SetSpawnInfo( playerid, 0, 285, 49.1121,423.5605,12.7379,266.2521, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    }
    return 1;
}
Reply
#2

I don't think Spawning player at the instant he dies will work, instead use TogglePlayerSpectating to skip Class selection.
Reply
#3

I've attempted to do..
Now i got this.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    if(PlayerInfo[playerid][pTeam] == 1)
    {
    SetSpawnInfo( playerid, 0, 294, 195.5586,427.2332,12.7379,93.6763, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid, 1);
    SetTimerEx("anticlass", 5000, false, "i", playerid);
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
    SetSpawnInfo( playerid, 0, 285, 49.1121,423.5605,12.7379,266.2521, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid, 1);
    SetTimerEx("anticlass", 5000, false, "i", playerid);
    }
    TextDrawHideForPlayer(playerid, VHealth[playerid]);
    TextDrawHideForPlayer(playerid, Stats[playerid]);
    TextDrawHideForPlayer(playerid, VArmour[playerid]);
    TextDrawHideForPlayer(playerid, VLevel[playerid]);
    TextDrawHideForPlayer(playerid, VCash[playerid]);
    TextDrawHideForPlayer(playerid, VPlayer[playerid]);
    return 1;
}
But it doesn't skip Class Selection.

This is the AntiClass timer.

pawn Код:
forward anticlass(playerid);
public anticlass(playerid)
{
    TogglePlayerSpectating(playerid, 0);
    return 1;
}
Reply
#4

You cannot set player's position in OnPlayerDeath.
Reply
#5

So i have to turn these information on ''OnPlayerSpawn''?
Reply
#6

Yes.
Reply
#7

K, So i got these now..
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pTeam] == 1)
    {
    SetSpawnInfo( playerid, 0, 294, 195.5586,427.2332,12.7379,93.6763, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
    SetSpawnInfo( playerid, 0, 285, 49.1121,423.5605,12.7379,266.2521, 0, 0, 0, 0, 24, 50);
    SpawnPlayer(playerid);
    }
    TextDrawShowForPlayer(playerid, VHealth[playerid]);
    TextDrawShowForPlayer(playerid, Stats[playerid]);
    TextDrawShowForPlayer(playerid, VArmour[playerid]);
    TextDrawShowForPlayer(playerid, VLevel[playerid]);
    TextDrawShowForPlayer(playerid, VCash[playerid]);
    TextDrawShowForPlayer(playerid, VPlayer[playerid]);

    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    TextDrawHideForPlayer(playerid, VHealth[playerid]);
    TextDrawHideForPlayer(playerid, Stats[playerid]);
    TextDrawHideForPlayer(playerid, VArmour[playerid]);
    TextDrawHideForPlayer(playerid, VLevel[playerid]);
    TextDrawHideForPlayer(playerid, VCash[playerid]);
    TextDrawHideForPlayer(playerid, VPlayer[playerid]);
    return 1;
}
But when i want to spawn, it's really bugging me.
It freezed the player.
and the weapons keep switching.
Also.. when i attempt to move my camera. it moves back.
Reply
#8

OnPlayerRequestSpawn / Or your login script add those SetSpawnInfo
Hide all textdraws OnDeath and OnDisconnect
Show Textdraws on Spawn.
Reply
#9

this is the Login system.
pawn Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
And this is on playerrequestspawn
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pTeam] == 1)
    {
        SendClientMessage(playerid, COLOR_RED, "Welcome, You are Terrorist now. Keep Killing Counter Terrorists.");
        SendClientMessage(playerid, COLOR_GREY, "Use /commands to vieuw all commands!");
        SetSpawnInfo( playerid, 0, 294, 195.5586, 427.2332, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
        SpawnPlayer(playerid);
        TogglePlayerControllable(playerid,1);
        SetPlayerInterior(playerid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        SetTimerEx("Unfreeze", 5000, false, "i", RPN(playerid));
        return 0;
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
        SendClientMessage(playerid, COLOR_BLUE, "Welcome, You are an Counter Terrorist now. Keep Killing Terrorists.");
        SendClientMessage(playerid, COLOR_GREY, "Use /commands to vieuw all commands!");
        SetSpawnInfo( playerid, 0, 285, 49.1121, 423.5605, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
        SpawnPlayer(playerid);
        TogglePlayerControllable(playerid,1);
        SetPlayerInterior(playerid, 0);
        SetPlayerVirtualWorld(playerid, 0);
        SetTimerEx("Unfreeze", 5000, false, "i", RPN(playerid));
        return 0;
    }
    return 1;
}
So what do i have to do exactly?
Reply
#10

When a player dies, it calls the OnPlayerSpawn. What you do is: set spawn info for the player and re-spawn him.

This should work fine
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pTeam] == 1)
    {
        SetPlayerSkin( playerid, 294 );
        SetPlayerPos( playerid, 195.5586, 427.2332, 12.7379 );
        SetPlayerFacingAngle( playerid, 93.6763 );
        GivePlayerWeapon( playerid, 24, 50 );
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
        SetPlayerSkin( playerid, 285 );
        SetPlayerPos( playerid, 49.1121, 423.5605, 12.7379 );
        SetPlayerFacingAngle( playerid, 266.2521 );
        GivePlayerWeapon( playerid, 24, 50 );
    }
    SetCameraBehindPlayer(playerid);
   
    TextDrawShowForPlayer(playerid, VHealth[playerid]);
    TextDrawShowForPlayer(playerid, Stats[playerid]);
    TextDrawShowForPlayer(playerid, VArmour[playerid]);
    TextDrawShowForPlayer(playerid, VLevel[playerid]);
    TextDrawShowForPlayer(playerid, VCash[playerid]);
    TextDrawShowForPlayer(playerid, VPlayer[playerid]);

    return 1;
}
Reply
#11

Quote:
Originally Posted by Dwane
Посмотреть сообщение
When a player dies, it calls the OnPlayerSpawn. What you do is: set spawn info for the player and re-spawn him.

This should work fine
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pTeam] == 1)
    {
        SetPlayerSkin( playerid, 294 );
        SetPlayerPos( playerid, 195.5586, 427.2332, 12.7379 );
        SetPlayerFacingAngle( playerid, 93.6763 );
        GivePlayerWeapon( playerid, 24, 50 );
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
        SetPlayerSkin( playerid, 285 );
        SetPlayerPos( playerid, 49.1121, 423.5605, 12.7379 );
        SetPlayerFacingAngle( playerid, 266.2521 );
        GivePlayerWeapon( playerid, 24, 50 );
    }
    SetCameraBehindPlayer(playerid);
   
    TextDrawShowForPlayer(playerid, VHealth[playerid]);
    TextDrawShowForPlayer(playerid, Stats[playerid]);
    TextDrawShowForPlayer(playerid, VArmour[playerid]);
    TextDrawShowForPlayer(playerid, VLevel[playerid]);
    TextDrawShowForPlayer(playerid, VCash[playerid]);
    TextDrawShowForPlayer(playerid, VPlayer[playerid]);

    return 1;
}
Thanks, but it doesn't skip the Class Selection, when someone dies.
Reply
#12

Код:
public OnPlayerRequestSpawn(playerid)
{
    if(PlayerInfo[playerid][pTeam] == 1)
    {
        SendClientMessage(playerid, COLOR_RED, "Welcome, You are Terrorist now. Keep Killing Counter Terrorists.");
        SetSpawnInfo( playerid, 0, 294, 195.5586, 427.2332, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
    }
    else if(PlayerInfo[playerid][pTeam] == 2)
    {
        SendClientMessage(playerid, COLOR_BLUE, "Welcome, You are an Counter Terrorist now. Keep Killing Terrorists.");
        SetSpawnInfo( playerid, 0, 285, 49.1121, 423.5605, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
    }
    else { return 0; }
    SendClientMessage(playerid, COLOR_GREY, "Use /commands to vieuw all commands!");
    SpawnPlayer(playerid);
    TogglePlayerControllable(playerid, 0);
    SetPlayerInterior(playerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    SetTimerEx("Unfreeze", 5000, false, "i", RPN(playerid)); // IN THIS TIMER TogglePlayerControllable(playerid, 1);
    return 1;
}
Edit:
If this does not work remove the SpawnPlayer line.
Reply
#13

Wait. The class selection is being shown when a player press F4 and then die.
What do you want to do?
Reply
#14

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Wait. The class selection is being shown when a player press F4 and then die.
What do you want to do?
Well, I want the class selection, only when a player connects.. not when he dies.
So i want to skip it, every time he dies.
Reply
#15

It shouldn't be called everytime someone dies. It doesn't do that for me if I don't press F4 and then kill myself.

Does it show the class selection everytime someone dies? If yes, it's a script's fault. It shouldn't do that.

EDIT: You can prevent it though. This may works.

pawn Код:
new
    isDead[ MAX_PLAYERS ]
;

// OnPlayerConnect
isDead[ playerid ] = 0;

// OnPlayerDeath
isDead[ playerid ] = 1;

// OnPlayerSpawn
if( isDead[ playerid ] == 1 ) isDead[ playerid ] = 0;

// OnPlayerRequestClass
if( isDead[ playerid ] == 1 ) SpawnPlayer( playerid );
Reply
#16

Yes, it does.
But i cant find the scrpt fault.

EDIT;

Well, Now i got this..
at OnPlayerRequestClass

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    new string[128];
    SetPlayerPos(playerid, 786.2990,845.2061,176.7938);
    SetPlayerCameraPos(playerid, 779.6148,845.5803,180.1051);
    SetPlayerCameraLookAt(playerid, 786.2990,845.2061,176.7938);
    if( isDead[ playerid ] == 1 ) SpawnPlayer( playerid );
    if(classid == 0)
    {
        format(string, sizeof(string), "~r~Terrorists");
        GameTextForPlayer(playerid, string, 3000, 6);
        SetPlayerSkin(playerid, 294);
        PlayerInfo[playerid][pTeam] = 1;
        SetPlayerColor(playerid, COLOR_RED);
        return 0;
    }
    else if(classid == 1)
    {
        format(string, sizeof(string), "~b~Counter-Terrorists");
        GameTextForPlayer(playerid, string, 3000, 6);
        SetPlayerSkin(playerid, 285);
        PlayerInfo[playerid][pTeam] = 2;
        SetPlayerColor(playerid, COLOR_BLUE);
        return 0;
    }
    return 1;
}
And it doesn't skip the Class selection. :S
Reply
#17

Alright, I tried this and it works for me. I may overdid it, but give a try!
pawn Код:
new
    isDead[ MAX_PLAYERS ],
    class_selection[ MAX_PLAYERS ]
;

public OnPlayerRequestClass( playerid, classid )
{
    class_selection[ playerid ] = 1;
    if( isDead[ playerid ] == 1 && class_selection[ playerid ] == 1 )
    {
        SetSpawnInfo( ... ); // Edit it
        SpawnPlayer( playerid );
        return 1;
    }
    // rest of setting up the place
    return 1;
}

public OnPlayerConnect( playerid )
{
    isDead[ playerid ] = 0;
    class_selection[ playerid ] = 0;
    return 1;
}

public OnPlayerSpawn( playerid )
{
    SetPlayerInterior( playerid, 0 );
    SetCameraBehindPlayer( playerid );
    if( isDead[ playerid ] == 1 && class_selection[ playerid ] == 1 )
    {
        isDead[ playerid ] = 0;
        class_selection[ playerid ] = 0;
    }
    if( isDead[ playerid ] == 1 ) isDead[ playerid ] = 0;
    if( class_selection[ playerid ] == 1 ) class_selection[ playerid ] = 0;
    return 1;
}

public OnPlayerDeath( playerid, killerid, reason )
{
    isDead[ playerid ] = 1;
    return 1;
}
I tested and everytime I used f4 and /kill, it didn't teleport me to the class selection as it should do that, but it spawned me instead. I'm sure it will work for you!
Reply
#18

But, If they connect.. i want them to choose their team.
Reply
#19

You can do that in OnPlayerRequestClass, it allows you.
Reply
#20

Ok, I got this now.

The problem.. Yes, It doesnt return to class selection, when he dies.
even if he presses F4.
But.. If a player connects... he cant choose his team?

pawn Код:
public OnPlayerRequestClass( playerid, classid )
{
   class_selection[ playerid ] = 1;
   if(class_selection[ playerid ] == 0)
   {
    new string[128];
    SetPlayerPos(playerid, 786.2990,845.2061,176.7938);
    SetPlayerCameraPos(playerid, 779.6148,845.5803,180.1051);
    SetPlayerCameraLookAt(playerid, 786.2990,845.2061,176.7938);
    if( isDead[ playerid ] == 1 ) SpawnPlayer( playerid );
    if(classid == 0)
    {
        format(string, sizeof(string), "~r~Terrorists");
        GameTextForPlayer(playerid, string, 3000, 6);
        SetPlayerSkin(playerid, 294);
        PlayerInfo[playerid][pTeam] = 1;
        SetPlayerColor(playerid, COLOR_RED);
        return 0;
    }
    else if(classid == 1)
    {
        format(string, sizeof(string), "~b~Counter-Terrorists");
        GameTextForPlayer(playerid, string, 3000, 6);
        SetPlayerSkin(playerid, 285);
        PlayerInfo[playerid][pTeam] = 2;
        SetPlayerColor(playerid, COLOR_BLUE);
        return 0;
    }
   }
   if( isDead[ playerid ] == 1 && class_selection[ playerid ] == 1 )
   {
     if(PlayerInfo[playerid][pAdmin] == 1)
     {
        SetSpawnInfo( playerid, 0, 294, 195.5586, 427.2332, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
        SpawnPlayer( playerid );
     }
     else if(PlayerInfo[playerid][pTeam] == 2)
     {
        SetSpawnInfo( playerid, 0, 285, 49.1121, 423.5605, 12.7379, 269.15, 0, 0, 0, 0, 24, 50 );
        SpawnPlayer( playerid );
     }
     return 1;
   }
   return 1;
}
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)