'spawn' button after death.
#1

So when the player dies, it sets a cj skin in blueberry acres, and once they press 'spawn' that when it teleports them back to their death pos and applys animation..

I need it so when the player dies it just re spawns him at the location with his original skin and not having to press the /spawn option.

ON PLAYER DEATH:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new pname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME], string[128], Float: X, Float: Y, Float: Z;

	GetPlayerName(playerid, pname, sizeof(pname)), GetPlayerName(killerid, kname, sizeof(kname));
	GetPlayerPos(playerid, X, Y, Z);
	
	pDeathPosX[playerid] = X;
	pDeathPosY[playerid] = Y;
	pDeathPosZ[playerid] = Z;

	pInfo[playerid][Mask] = 0;
	pDeathMode[playerid] = 1;

	if(killerid != INVALID_PLAYER_ID)
	{
	    format(string, sizeof(string), "%d %s has just killed %d %s using a %s (%d)", killerid, kname, playerid, pname, GunName[reason], reason);
	    SendAdminMessage(COLOR_YELLOW, string);
	}

	return 1;
}
ON PLAYER SPAWN:

Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerColor(playerid, 1);
	TogglePlayerSpectating(playerid, 0);
	
	if(pDeathMode[playerid] == 1)
	{
 	    SetPlayerPos(playerid, pDeathPosX[playerid], pDeathPosY[playerid], pDeathPosZ[playerid]);

		SetPlayerHealth(playerid, 100);
	    TogglePlayerControllable(playerid, false);
        SetPlayerSkin(playerid, pInfo[playerid][Skin]);
	    SendClientMessage(playerid, -1, "You've lost consciousness!");
		SetTimerEx("PlayerDeathMode", 1500, false, "i", playerid);
	}

	else if(pDeathMode[playerid] == 2)
	{
		SetPlayerColor(playerid, -1);
		pDeathMode[playerid] = 0;
        SetPlayerSkin(playerid, pInfo[playerid][Skin]);
	    SetPlayerPos(playerid, 43.6618, -188.0078, 2.2442);
	    SetPlayerHealth(playerid, 70);
	}
	
	else if(pInfo[playerid][LastPos] == 0) SetPlayerPos(playerid, 250.7732, -193.0894, 2.0562);

	ResetPlayerMoney(playerid); // doing this avoids HandMoney to duplicate (aka get 2x the amount u had earlier)
    GivePlayerMoney(playerid, pInfo[playerid][HandMoney]);
	SetPlayerSkin(playerid, pInfo[playerid][Skin]);

	GivePlayerWeapon(playerid, pInfo[playerid][Weapon1], pInfo[playerid][Wep1Ammo]);
	GivePlayerWeapon(playerid, pInfo[playerid][Weapon2], pInfo[playerid][Wep2Ammo]);
	GivePlayerWeapon(playerid, pInfo[playerid][Weapon3], pInfo[playerid][Wep3Ammo]);
	GivePlayerWeapon(playerid, pInfo[playerid][Weapon4], pInfo[playerid][Wep4Ammo]);
	GivePlayerWeapon(playerid, pInfo[playerid][Weapon5], pInfo[playerid][Wep5Ammo]);

	// ---- System rewrites (bug fixed) ---- //

	if(pInfo[playerid][Registered] == 0) RegisterFix(playerid);

	SetPlayerHealth(playerid, pInfo[playerid][Health]);
	SetPlayerArmour(playerid, pInfo[playerid][Armour]);

	//TextDrawShowForPlayer(playerid, wMark0);
	//TextDrawShowForPlayer(playerid, wMark1);
	
	return 1;
}
Reply
#2

Make a bool like ClassDisabled[MAX_PLAYERS] and use it to skip class selection. Like:
PHP код:
OnPlayerDeath(.....)
{
    
ClassDisabled[playerid]=true;
}
OnPlayerRequestClass(....)
{
    if(
ClassDisabled[playerid]) return 1;

And don't forget to change that bool in different situations.
Reply
#3

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Make a bool like ClassDisabled[MAX_PLAYERS] and use it to skip class selection. Like:
PHP код:
OnPlayerDeath(.....)
{
    
ClassDisabled[playerid]=true;
}
OnPlayerRequestClass(....)
{
    if(
ClassDisabled[playerid]) return 1;

And don't forget to change that bool in different situations.
Never worked directly with bools, what new would i need to make?
Reply
#4

Just this:
PHP код:
new bool:ClassDisabled[MAX_PLAYERS]; 
on top.
Reply
#5

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Just this:
PHP код:
new bool:ClassDisabled[MAX_PLAYERS]; 
on top.
gonna try that, give me a minute
Reply
#6

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
gonna try that, give me a minute
Okay, it's doing the same, when I die it spawns me under blueberry acres with cj skin, I've added the bool under onplayerrequestclass and onplayerdeath..
Reply
#7

Show the new code.
Reply
#8

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Show the new code.
I fixed it by simply doing this..

Код:
public OnPlayerRequestClass(playerid, classid)
{
    SpawnPlayer(playerid);
    TogglePlayerSpectating(playerid, true);
	return 1;
}
But it sends my "you are dead" message twice :/
Reply
#9

Returning a value simply won't do anything. You have to also use SpawnPlayer in the callback with a timer.

pawn Код:
new classenable[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
     if(! classenable[playerid]) return SetTimerEx("Call_Spawn", 350, false, "i", playerid);
     return 1;
}

forward Call_Spawn(playerid);
public Call_Spawn(playerid) return SpawnPlayer(playerid);
And you receive the message twice because of TogglePlayerSpectating.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)