SA-MP Forums Archive
How can i do this ? - 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: How can i do this ? (/showthread.php?tid=302115)



How can i do this ? - Ronaldo_raul™ - 07.12.2011

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™.


Re: How can i do this ? - cod4esle - 07.12.2011

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


Re: How can i do this ? - Ronaldo_raul™ - 07.12.2011

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


Re: How can i do this ? - CSSI - 07.12.2011

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.


Re: How can i do this ? - sim_sima - 07.12.2011

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


Re: How can i do this ? - CSSI - 07.12.2011

it would be Under OnPlayerSpawn not OnPlayerDeath xD


Re: How can i do this ? - Ronaldo_raul™ - 07.12.2011

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


Re: How can i do this ? - Ronaldo_raul™ - 08.12.2011

BUMP ?


Re: How can i do this ? - suhrab_mujeeb - 10.12.2011

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.


Re: How can i do this ? - Ronaldo_raul™ - 26.12.2011

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 ?