20.12.2013, 18:25
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;
}