Spawn After Death
#1

hello SAMP's
i have a problem with "OnPlayerDeath" after dying, it always return to class selection
why it didn't spawn randomly like usual?
i am using GRAND LARCENY 1.0 gamemode
Reply
#2

so i think u have this:
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
playercash;
    
    
gPlayerHasCitySelected[playerid] = 0;
    
    if(
killerid == INVALID_PLAYER_ID) {
        
ResetPlayerMoney(playerid);
    } else {
        
playercash GetPlayerMoney(playerid);
        if(
playercash 0)  {
            
GivePlayerMoney(killeridplayercash);
            
ResetPlayerMoney(playerid);
        }
    }
       return 
1;

if so payers will go back to city selection then class selection remove the OnplayerDeath function and remplace it with this one.
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
playercash;
     
    if(
killerid == INVALID_PLAYER_ID) {
        
ResetPlayerMoney(playerid);
    } else {
        
playercash GetPlayerMoney(playerid);
        if(
playercash 0)  {
            
GivePlayerMoney(killeridplayercash);
            
ResetPlayerMoney(playerid);
        }
    }
       return 
1;

Reply
#3

Edit: Already posted - You must of been posting at the sametime.
Reply
#4

Quote:
Originally Posted by Stones
Посмотреть сообщение
Edit: Already posted - You must of been posting at the sametime.
Yeah after 12 minutes :P.
Reply
#5

I'm curious, what does playermoney have anything to do with going back to class selection after dying or not?

Look for ForClassSelection in your code.

PHP код:
// Sends the player back to class selection
COMMAND:reclass(playeridparams[])
{
    
// Force the player back into class-selection
    
ForceClassSelection(playerid);
    
// Turning spectator mode on and off again makes the player respawn inside class-selection after using "ForceClassSelection"
    
TogglePlayerSpectating(playeridtrue);
    
TogglePlayerSpectating(playeridfalse);
    
// Let the server know that this was a valid command
    
return 1;
}
// Kills the player
COMMAND:kill(playeridparams[])
{
    
// Kill the player by setting his health to 0
    
SetPlayerHealth(playerid0.0);
    
// Let the server know that this was a valid command
    
return 1;

I have these commands in my own gamemode.

When I die, or use the /kill command, I respawn as usual, everytime.

When I use /reclass, I'll end up in class selection and can spawn again.
When I die the first time after respawning (after having used /reclass), I'll end up in class selection again.
From the second time I die (and everytime after that), I respawn as usual without going to class selection.

So it's actually ForceClassSelection which sends you back to class selection when you die.
It requires you to die first to cancel returning to class selection feature of that command.

Your script may have ForceClassSelection inside OnPlayerSpawn or OnPlayerDeath, sending you to class selection everytime you die.

PHP код:
// Sends the player back to class selection
COMMAND:reclass(playeridparams[])
{
    
// Force the player back into class-selection
    
ForceClassSelection(playerid);
    
// Kill the player by setting his health to 0
    
SetPlayerHealth(playerid0.0);
    
// Let the server know that this was a valid command
    
return 1;

If I would use this command to get to class selection, you go to class selection as well.
But after spawning, you won't go back to class selection when you die the first time.
Reply
#6

Quote:
Originally Posted by aymane123
Посмотреть сообщение
if so payers will go back to city selection then class selection remove the OnplayerDeath function and remplace it with this one.
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
playercash;
     
    if(
killerid == INVALID_PLAYER_ID) {
        
ResetPlayerMoney(playerid);
    } else {
        
playercash GetPlayerMoney(playerid);
        if(
playercash 0)  {
            
GivePlayerMoney(killeridplayercash);
            
ResetPlayerMoney(playerid);
        }
    }
       return 
1;

i'm sorry, it's working with original grandlarc not on my edited grandlarc

hmm... for some reason, after dying it returns to city selection, how do i skip that after dying? is it possible to skip city selection after dying?
by the way, i use a code to save player's position, will this conflict with "OnPlayerDeath"?
well i think it's not, because it saves after player disconnects and loads before spawning correct me if i'm wrong
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)