[Include] OnPlayerSpawnEx (OPSex) - Make everything easy
#1

OnPlayerSpawnEx (OPSex) - Make everything easy


v1.1 is just released today more features like detecting if player respawn

Introduction

Well i'm bored today,

While browsing in the forum, i have idea.

I build this include for scripters.

Ex.

A Scripter wants a dialog pop up OnPlayerSpawn (Will not show the dialog again after death)
instead of creating global player variables (variables). OnPlayerSpawnEx is build to do that.

Example

PHP код:
public OnPlayerSpawnEx(playeridhasspawned)
{
    if(
hasspawned == FIRST_SPAWN//If player's first spawn)
    
{
        
ShowPlayerDialog(playerid123DIALOG_STYLE_MSGBOX"Debug""It work""Yes""");
    }
    else if(
hasspawned == SEC_SPAWN//if player's second spawn (even 3rd etc.. spawn)
    
{
        
SendClientMessage(playerid, -1"It's your second spawn!");
    }
    else if(
hasspawned == RESPAWN//if player respawn (only called when SetPlayerToRespawn is called)
    
{
        
SendClientMessage(playerid, -1"You've respawned!");
        
varSpawn[playerid] = FIRST_SPAWN//you've to do this so OnPlayerSpawnEx stops detecting you respawning even you didn't respawn.
    
}
    return 
1;

Other Notes

I also notice that the include disables OnPlayerSpawn.

OnPlayerSpawn will not called anymore.

So i suggest you to put all your codes from OnPlayerSpawn to OnPlayerSpawnEx.

Other notes, I don't found a bug..

How to use it

First of all, When player connects OnPlayerSpawnEx parameter, hasspawned is set to 0.
To avoid the problems. hasspawned is set to 1 after OnPlayerSpawnEx is called.

Код:
0 = FIRST_SPAWN
1 = SEC_SPAWN
2 = RESPAWN
OnPlayerSpawnEx has 2 parameters

Код:
playerid - the player (the one who will spawn)
hasspawned - checks if player has the FIRST_SPAWN or the SEC_SPAWN
OnPlayerSpawnEx works the same like OnPlayerSpawn but the difference is the parameters is added.

You could also do like this

PHP код:
public OnPlayerSpawnEx(playeridhasspawned)
{
    
printf("[debug] OnPlayerSpawnEx results parameters of hasspawned: %d"hasspawned);
    return 
1;

It can be also used for classes.

SetPlayerToRespawn(playerid)

It works the same like SpawnPlayer, doesn't work OnPlayerConnect, OnPlayerRequestClass..

It sets the hasspawned to RESPAWN, you've to set hasspawned to 0 by yourself to avoid the problems.

Note: If hasspawned (varSpawn) is not set back to 0 after player spawn, in next spawn the include will detect the player that he respawn.

IsPlayerSpawned(playerid)

It works the same like other native functions of SA-MP

pawn Код:
if(IsPlayerSpawned(playerid) == FIRST_SPAWN) print("[debug] 0");
Downloadlink

Pastebin - v1.0
Mediafire - v1.0

Pastebin - v1.1
Mediafire - v1.1

Thank you for using OnPlayerSpawnEx (OPSex).inc
Reply


Messages In This Thread
OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 15.10.2012, 10:37
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Emmet_ - 15.10.2012, 10:41
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 15.10.2012, 10:43
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Emmet_ - 15.10.2012, 10:48
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 15.10.2012, 10:53
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 15.10.2012, 10:59
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 15.10.2012, 11:26
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Niko_boy - 15.10.2012, 13:51
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by fiki574 - 16.10.2012, 08:13
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by razvan20100 - 16.10.2012, 08:19
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Lordzy - 16.10.2012, 11:26
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by HuSs3n - 16.10.2012, 21:10
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 19.10.2012, 09:03
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 19.10.2012, 09:28
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by RajatPawar - 19.10.2012, 11:53
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Mafioso97 - 19.10.2012, 14:44
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by JaKe Elite - 20.10.2012, 00:52
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Excips - 23.10.2012, 16:30
Re: OnPlayerSpawnEx (OPSex) - Make everything easy - by Skillet` - 23.10.2012, 16:48

Forum Jump:


Users browsing this thread: 1 Guest(s)