Respawning in Dm Zone
#1

Hello there,

I need some help with respawning in Dm .

I created a variable called inDM, and applied it to the dm command, i also made a /leavedm command, but i was wondering how can i make the player respawn in dm zone if he is in one, just to keep in mind that i want multiple Dm zone and i am planning to keep the same command "/leavedm" for all the dm zones.

Here is my DM command Code:

pawn Код:
COMMAND:dm(playerid,params[])
{
if(!strcmp(params, "1"))//if area 51 was typed after a space
{
if(inDM[playerid] == 1)
{
SendClientMessage(playerid,COLOR_PINK2,"Error: You are already in DeathMatch Arena");
}
else
{
new rand = random(sizeof(Randlounge));
new string[500];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
inDM[playerid] = 1;
GetPlayerPos(playerid, p[0], p[1], p[2]);
SetPlayerPos(playerid,Randdm[rand][0], Randdm[rand][1],Randdm[rand][2]);
Freeze(playerid,5);
format(string, sizeof(string),"{CC8152}%s has joined Deathmatch 1 | Weapons: Deagle - Shotgun", name);
SendClientMessageToAll(-1,string);
SendClientMessage(playerid,0x92DADEAA,"Welcome to Deathmatch arena 1");
SendClientMessage(playerid,0xE3D68DAA,"Please wait 5 seconds for the objects to be loaded");
}
}
return 1;
}
Just in case, my leave dm

pawn Код:
COMMAND:leavedm(playerid,params[])
{
if(inDM[playerid] == 0)
{
SendClientMessage(playerid,COLOR_PINK2,"Error: You are not in a Deathmatch Arena");
}
else
{
inDM[playerid] = 0;
SendClientMessage(playerid,COLOR_PINK2,"You left the DeathMatch Arena");
SetPlayerPos(playerid, p[0], p[1], p[2]);
}
return 1;
}
Please help with this problem. Thanks in advance
Reply
#2

Bump
Reply
#3

Do you mean respawning to dm after dying ?
Reply
#4

This should work, the current code you have will not work, because you don't save the current location of that player.

pawn Код:
new SavePosition[MAX_PLAYERS][3], Float:LoadPosition[MAX_PLAYERS][3]; //set as global variable.


COMMAND:dm(playerid,params[])
{
    if(!strcmp(params, "1"))//if area 51 was typed after a space
    {
        if(inDM[playerid] == 1)
            return SendClientMessage( playerid, COLOR_PINK2,"Error: You are already in DeathMatch Arena");
       
        new rand = random( sizeof( Randlounge ) ), name[ 24 ], string[ 128 ]; //no need for size 500, waste of memory.


        GetPlayerName(playerid, name, sizeof(name));

        inDM[playerid] = 1;


        GetPlayerPos(playerid, SavePosition[playerid][0], SavePosition[playerid][1], SavePosition[playerid][2]);
       
        SavePosition[playerid][0] = LoadPosition[playerid][0];
        SavePosition[playerid][1] = LoadPosition[playerid][1];
        SavePosition[playerid][2] = LoadPosition[playerid][2];

        SetPlayerPos(playerid,Randdm[rand][0], Randdm[rand][1],Randdm[rand][2]);

        Freeze(playerid, 5);

        format(string, sizeof(string),"{CC8152}%s has joined Deathmatch 1 | Weapons: Deagle - Shotgun", name);
        SendClientMessageToAll(-1,string);

        SendClientMessage(playerid,0x92DADEAA,"Welcome to Deathmatch arena 1");
        SendClientMessage(playerid,0xE3D68DAA,"Please wait 5 seconds for the objects to be loaded");
    }
    return 1;
}

COMMAND:leavedm(playerid,params[])
{
    if(inDM[playerid] == 0)
        return SendClientMessage(playerid,COLOR_PINK2,"Error: You are not in a Deathmatch Arena");

    inDM[playerid] = 0;
    SendClientMessage(playerid,COLOR_PINK2,"You left the DeathMatch Arena");
    SetPlayerPos(playerid, LoadPosition[playerid][0], LoadPosition[playerid][1], LoadPosition[playerid][2]);
    return 1;
}
Reply
#5

Thankd for helping, but i tried a dufferent way and it works pretty well. if anything causes problem i will try your code.

+rped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)