SA-MP Forums Archive
DM spawn after death - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: DM spawn after death (/showthread.php?tid=445277)



DM spawn after death - martoivanov - 20.06.2013

I created a DM zone and my problem is that when a player die it spawns it at random spawn positions. I want to spawn again in the the area. How can i do this?
here is my code from the teleport:
pawn Код:
CMD:minigun(playerid, params[])
    {
        if(GetPVarType(playerid, "DMZONE") != 0) return SendClientMessage(playerid, red, "bla bla!(/leavedm)");
        SetPVarInt(playerid, "DMZONE", 1); // set the pvar to show that they're in a DM zone
        if(Teled[playerid] == 1) return SendClientMessage(playerid,red," test...(/leavedm)");
        Teled[playerid] = 1;
        new mR = random(sizeof(MinigunRandom));
        SetPlayerPos(playerid, MinigunRandom[mR][0], MinigunRandom[mR][1], MinigunRandom[mR][2]);
        GameTextForPlayer(playerid, "~w~minigun deathmatch", 4000, 6);
        SetPlayerInterior(playerid, 0);
        new pName[24];
        new str[128];
        GetPlayerName(playerid, pName, 24);
        format(str, 128, "%s joined /minigun", pName);
        SendClientMessageToAll(COLOR_TELEPORT, str);
        SetPlayerInterior(playerid, 0);
        SetPlayerHealth(playerid, 100);
        GivePlayerWeapon(playerid, 38, 99999999);

        return 1;
    }



Re: DM spawn after death - dEcooR - 20.06.2013

Just put this onplayerspawn(playerid);

Код:
SetPlayerPos(playerid, MinigunRandom[mR][0], MinigunRandom[mR][1], MinigunRandom[mR][2]);
SetPlayerInterior(playerid,0);



Re: DM spawn after death - martoivanov - 20.06.2013

But this will spawn him every time there? I want only after death in DM zone


Re: DM spawn after death - dEcooR - 20.06.2013

I think that if player death its called this onplayerspawn so you should make it

or try this

Код:
new death[MAX_PLAYERS]; // up

onplayerconnect()
{
death[playerid] = 0;
}

onplayerdeath(..)
{
death[playerid] = 1;
}

onplayerspawn(..)
{
if(death[playerid] = 1) SetPlayerPos(playerid, MinigunRandom[mR][0], MinigunRandom[mR][1], MinigunRandom[mR][2]);
}



Re: DM spawn after death - martoivanov - 20.06.2013

But i don't want every time when someone dies to teleport him into DM..


Re: DM spawn after death - Niko_boy - 20.06.2013

from ur code i can see : Teled[playerid] = 1; is ur variable checking if player in DM

so in SPawn do this:
pawn Код:
if( Teled[playerid] == 1 ) {
//spawn in DM
}
means u need a variable check showing that if player in DM


Re: DM spawn after death - dEcooR - 20.06.2013

yop or this SetPVarInt(playerid, "DMZONE", 1);

use this onplayerspawn if(getpvarint("dmzone") == 1) setplayerpos..


Re: DM spawn after death - martoivanov - 20.06.2013

I understood you all but this var
pawn Код:
Teled[playerid]
is used in many dm zones and if i type this in onplayerspawn, it will teleport him to the place of 1 dm zone. Is there another way of doing this?


Re: DM spawn after death - dEcooR - 20.06.2013

as i said try this onplayerspawn

if(GetPVarInt(playerid,"dmzone") == 1) setplayerpos(your dm)


Re: DM spawn after death - martoivanov - 21.06.2013

Read what i said! If i white this it will spawn him at the coordinates of one teleport only. For example, I have /minigun and /area51 and if the player dies, it will always teleport him to minigun coordinates(if i put them in onplayerspawn). What i have to do?