SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/08/2017, 12:38 AM   #11
oMa37
Gangsta
 
oMa37's Avatar
 
Join Date: Feb 2016
Posts: 973
Reputation: 136
Default Re: OnPlayerDeath getting called twice

OnPlayerDeath gets called twice ONLY when the player is in event (in other words, when SpawnEx[playerid] = true).
Check the codes and check the debugs.
oMa37 is offline   Reply With Quote
Old 13/08/2017, 06:18 AM   #12
GaByM
Little Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Posts: 49
Reputation: 0
Default Re: OnPlayerDeath getting called twice

Look how I see your problem: The player dies and when he spawns SOMEONE or SOMETHING kills him [ SetPlayerHealth(playerid,0.0)? ], and because of this OnPlayerDeath gets called 1 more time.

Quote:
Originally Posted by oMa37 View Post
LastHealth variable will never be 0.0, I debugged it, it works fine
You may say you debugged LastHealth, but go and put a // in front of SetPlayerHealth at OnPlayerSpawn.
Look at your debug:
PHP Code:
[18:33:43Called OnPlayerDeath #2 
[18:33:43Called OnPlayerSpawn 
[18:33:43Called OnPlayerSpawn #2 
[18:33:43Called OnPlayerDeath #1 
[18:33:43Called OnPlayerRequestClass #1 
[18:33:43Called OnPlayerRequestClass #2 
[18:33:43Called OnPlayerSpawn 
The player dies (he's in event) - OnPlayerDeath #2; now the player spawns, and SpawnEx is still true so - OnPlayerSpawn #2; but it gets killed there so OnPlayerDeath is called again (this time with #1 because SpawnEx was set to false previously)

If this is not working go and find timers/anything else that can kill your player after spawning.
__________________
Sorry for my bad English.
GaByM is offline   Reply With Quote
Old 13/08/2017, 11:06 AM   #13
oMa37
Gangsta
 
oMa37's Avatar
 
Join Date: Feb 2016
Posts: 973
Reputation: 136
Default Re: OnPlayerDeath getting called twice

Guys .. The issue is not from LastHealth variable, there is nothing wrong with it!
I debugged it multiple times and even removed it and still the same, OnPlayerDeath got called twice again.

The issue must be from OnPlayerDeath, this happens ONLY when the player in event.
oMa37 is offline   Reply With Quote
Old 13/08/2017, 08:10 PM   #14
denNorske
Gangsta
 
denNorske's Avatar
 
Join Date: Nov 2011
Location: Narvik, Norway
Posts: 700
Reputation: 47
Default Re: OnPlayerDeath getting called twice

Show us proper debug logs, if you already have debugged it you can provide the output from it

Code:
[18:33:43] Called - OnPlayerDeath #2 
[18:33:43] Called - OnPlayerSpawn 
[18:33:43] Called - OnPlayerSpawn #2 
[18:33:43] Called - OnPlayerDeath #1 
[18:33:43] Called - OnPlayerRequestClass #1 
[18:33:43] Called - OnPlayerRequestClass #2 
[18:33:43] Called - OnPlayerSpawn
You can see that OnPlayerDeath Acts normally on #1, meaning that there's something wrong in #2 (more likely).
So my guess would be the mistake lies in here:

PHP Code:
if(SpawnEx[playerid] == true) { 

        
SpawnEx[playerid] = false
        
SendClientMessageToAll(-1"Called - OnPlayerSpawn #2"); 

        
SetPlayerInterior(playeridLastInterior[playerid]); 
        
SetPlayerHealth(playeridLastHealth[playerid]); 
        
SetPlayerArmour(playeridLastArmour[playerid]); 

        
InEvent[playerid] = 0
    } 
Try commenting out both armour and the health, debug the values, etc. - and show us.
__________________
OBJECT PARTITIONER
Ever wondered how to split up maps easily from one file? Check: Online Map Object Partitioner (Click)
[Filterscript] Circle Speedo: http://forum.sa-mp.com/showthread.php?p=3861785

You have the people that asks for rep, and those who doesn't like it at all:


Server Trailer: https://www.youtube.com/watch?v=jSKhbMFvAUs
denNorske is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerDeath is not getting called MichiEXE Scripting Help 2 23/05/2016 06:55 PM
OnPlayerDeath not being called zaibaslr2 Scripting Help 0 05/06/2015 08:19 AM
OnPlayerDeath isn't getting called correctly Luis- Scripting Help 3 26/11/2014 02:15 PM
OnPlayerDeath Not getting called. Black Wolf Scripting Help 16 16/01/2013 08:39 AM
OnPlayerDeath is not being called bigcomfycouch Help Archive 2 29/08/2010 07:09 AM


All times are GMT. The time now is 12:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.