How can i do this ?
#1

Hello everyone,
I want a piece of code that teleports the player in the DM area after his every death if he was in DM area before his death.If he type /leavedm than only he will be teleported to the other places.

Some appropriate code and answers will be helpful.

+rep guaranteed.

Regards,
Ronaldo_raul™.
Reply
#2

How in the world can we now how to check if he were in the DM area ? give the variable name please ...
Reply
#3

Ok sorry.
I am using -
pawn Код:
if(DMZone[playerid])
To check if the player is in the DM area or not!
Reply
#4

On OnPlayerSpawn check weather he was in DM or not using the variable if he is then use SetPlayerPos and teleport him to The Deathmatch Area.
Reply
#5

pawn Код:
public OnPlayerDeath(playerid, reason)
{
if(DMZone[playerid] == 1)
{
SetPlayerPos(playerid, YourX, YourY, YourZ);
}
return 1;
}
Remember to tabulate the text using the TAB button. I just wrote this fast directly on the forum
Reply
#6

it would be Under OnPlayerSpawn not OnPlayerDeath xD
Reply
#7

But i have more than 50 DM areas.How can i do that for each one ? Won't i mess up with the GM ?
Reply
#8

BUMP ?
Reply
#9

Ok, for example you got 3 commands for dm. This is the simplest untested way to do it.
pawn Код:
// Top of your script
new SpawnCheck[MAX_PLAYERS];
pawn Код:
// Under OnPlayerConnect and OnPlayerDisconnect
SpawnCheck[playerid] = 0;
- Edit

pawn Код:
// Commands for example
CMD: dm1(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 1;
    SetPlayerPos(playerid, dm1x, dm1y, dm1z);
    // rest of the code
}
CMD: dm2(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 2;
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
    // rest of the code
}
CMD: dm3(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 3;
    SetPlayerPos(playerid, dm3x, dm3y, dm3z);
    // rest of the code
}
pawn Код:
// So now you will use this for the spawn part
// Under your OnPlayerSpawn put this
if(SpawnCheck[playerid] == 1)
{
    SetPlayerPos(playerid, dm1x, dm1y, dm1z);
}
else if(SpawnCheck[playerid] == 2)
{
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
}
else if(SpawnCheck[playerid] == 3)
{
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
}
else return 1;
And for your /leavedm cmd
pawn Код:
CMD: leavedm(playerid, params[])
{
    SpawnCheck[playerid] = 0;
    // rest of the code
}
Just keep increasing the SpawnCheck[playerid] value for every command and the same goes in with the OnPlayerSpawn.
Reply
#10

Quote:
Originally Posted by suhrab_mujeeb
Посмотреть сообщение
Ok, for example you got 3 commands for dm. This is the simplest untested way to do it.
pawn Код:
// Top of your script
new SpawnCheck[MAX_PLAYERS];
pawn Код:
// Under OnPlayerConnect and OnPlayerDisconnect
SpawnCheck[playerid] = 0;
- Edit

pawn Код:
// Commands for example
CMD: dm1(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 1;
    SetPlayerPos(playerid, dm1x, dm1y, dm1z);
    // rest of the code
}
CMD: dm2(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 2;
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
    // rest of the code
}
CMD: dm3(playerid, params[])
{
    // Save this into the variable
    SpawnCheck[playerid] = 3;
    SetPlayerPos(playerid, dm3x, dm3y, dm3z);
    // rest of the code
}
pawn Код:
// So now you will use this for the spawn part
// Under your OnPlayerSpawn put this
if(SpawnCheck[playerid] == 1)
{
    SetPlayerPos(playerid, dm1x, dm1y, dm1z);
}
else if(SpawnCheck[playerid] == 2)
{
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
}
else if(SpawnCheck[playerid] == 3)
{
    SetPlayerPos(playerid, dm2x, dm2y, dm2z);
}
else return 1;
And for your /leavedm cmd
pawn Код:
CMD: leavedm(playerid, params[])
{
    SpawnCheck[playerid] = 0;
    // rest of the code
}
Just keep increasing the SpawnCheck[playerid] value for every command and the same goes in with the OnPlayerSpawn.
Erm ..i am encountering some problems.It works but after sometimes i always spawn at other place not in the DM area ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)