SA-MP Forums Archive
DM questions - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: DM questions (/showthread.php?tid=166052)



DM questions - Shockey - 07.08.2010

Ok guys I have some questions

if you teleport to a dm

and say the teleport is

SetPlayerPos(playerid, 000.00, 000.00, 000.00, 000.00);

just say that is the teleport but it isn't

ok when you die in the dm how can I make it respawn in the dm

and then when you teleport to a different location say /sf
it takes your weaps away

thx in advance if anyone can help


Re: DM questions - JaTochNietDan - 07.08.2010

You need to setup a way to check if the player is in the deathmatch or not OnPlayerDeath.

Example:

pawn Код:
public OnPlayerCommandText(playerid,params[])
{
    if(strcmp(cmdtext,"/dm",true) == 0)
    {
        SetPlayerPos(playerid,0.0,0.0,0.0);
        SetPVarInt(playerid,"in_DM",1); // Store the fact that he is in the deathmatch
        return 1;
    }

    if(strcmp(cmdtext,"/sf",true) == 0)
    {
        SetPlayerPos(playerid,0.0,0.0,0.0); // Take him away from DM
        ResetPlayerWeapons(playerid); // Take away his guns
        SetPVarInt(playerid,"in_DM",0); // Reset his PVariable
        return 1;
    }
    return 0;
}

public OnPlayerDeath(playerid)
{
    if(GetPVarInt(playerid,"in_DM")) // So he's still in the deathmatch
    {
        SetPlayerPos(playerid,0.0,0.0,0.0); // Put him back there
    }
    return 1;
}
Of course instead of checking the PVariable, you could also use the custom function IsPlayerInArea to see if he is in DM when he dies. There are many ways of doing it, pick which one works good for you.


Re: DM questions - Shockey - 07.08.2010

Ok thx and for other dms do I still use in_DM or not with the PVar


Re: DM questions - Hiddos - 07.08.2010

Two options: Use a different PVar for each DM or give all your DM zones an ID, so for when he types /dm2 you set his PVar to 2, /dm3 to 3, etc. Then check the DM in which he's supposed to be when he spawns again, and set his position according to that.


Re: DM questions - Shockey - 07.08.2010

Ok thx I will try it


Re: DM questions - Kevin_Joshen - 08.08.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You need to setup a way to check if the player is in the deathmatch or not OnPlayerDeath.

Example:

pawn Код:
public OnPlayerCommandText(playerid,params[])
{
    if(strcmp(cmdtext,"/dm",true) == 0)
    {
        SetPlayerPos(playerid,0.0,0.0,0.0);
        SetPVarInt(playerid,"in_DM",1); // Store the fact that he is in the deathmatch
        return 1;
    }

    if(strcmp(cmdtext,"/sf",true) == 0)
    {
        SetPlayerPos(playerid,0.0,0.0,0.0); // Take him away from DM
        ResetPlayerWeapons(playerid); // Take away his guns
        SetPVarInt(playerid,"in_DM",0); // Reset his PVariable
        return 1;
    }
    return 0;
}

public OnPlayerDeath(playerid)
{
    if(GetPVarInt(playerid,"in_DM")) // So he's still in the deathmatch
    {
        SetPlayerPos(playerid,0.0,0.0,0.0); // Put him back there
    }
    return 1;
}
Of course instead of checking the PVariable, you could also use the custom function IsPlayerInArea to see if he is in DM when he dies. There are many ways of doing it, pick which one works good for you.



tested.. still spawned me in the normal random spawns...


Re: DM questions - JaTochNietDan - 08.08.2010

Quote:
Originally Posted by Kevin_Joshen
Посмотреть сообщение
tested.. still spawned me in the normal random spawns...
Sorry, OnPlayerDeath wouldn't work with this. Use OnPlayerSpawn instead of OnPlayerDeath for that check.


Re: DM questions - Kevin_Joshen - 08.08.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Sorry, OnPlayerDeath wouldn't work with this. Use OnPlayerSpawn instead of OnPlayerDeath for that check.
tried it.. still spawned me in the wrong places..heres my entire OnPlayerSpawn

Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
    SetPlayerVirtualWorld(playerid,0);
    TextDrawHideForPlayer(playerid, Welcome);
    TextDrawHideForPlayer(playerid, TheBoxy);
    TextDrawHideForPlayer(playerid, Weilcome);
    TextDrawHideForPlayer(playerid, thelp);
    TextDrawHideForPlayer(playerid, ttele);
    TextDrawHideForPlayer(playerid, trules);
    TextDrawShowForPlayer(playerid, MoveCmd);
    TextDrawShowForPlayer(playerid, Textdraw0);
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw4);
    TextDrawShowForPlayer(playerid, Textdraw5);
    TextDrawShowForPlayer(playerid, Textdraw6);
    SetPlayerArmour(playerid,100);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,33,20);
    GivePlayerWeapon(playerid,4,1);
    GivePlayerWeapon(playerid,23,250);
    GivePlayerWeapon(playerid,28,200);
    GivePlayerWeapon(playerid,46,1);
    GivePlayerWeapon(playerid,41,100);
    GivePlayerMoney(playerid,15000);
    if(GetPVarInt(playerid,"in_DM")) // So he's still in the deathmatch
    {
            new rand = random(sizeof(MDM));
        SetPlayerPos(playerid,MDM[rand][PlayerX],MDM[rand][PlayerY],MDM[rand][PlayerZ]);
        SetPlayerInterior(playerid,10);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid,38,9999999);
 // Put him back there
    }


    new rand = random(4);
    switch (rand) {
        case 0:SetPlayerPos(playerid,405.9053,2456.6348,16.5000),SendClientMessage(playerid,COLOR_WHITE,"Spawn Info:You have been spawned at /aa!");
        case 1:SetPlayerPos(playerid,1318.2029,1284.1371,10.8203),SendClientMessage(playerid,COLOR_WHITE,"Spawn Info:You have been spawned at /lvair!");
        case 2:SetPlayerPos(playerid,1978.5294,-2617.4849,19.0112),SendClientMessage(playerid,COLOR_WHITE,"Spawn Info:You have been spawned at /lsair!");
        case 3:SetPlayerPos(playerid,-1454.7158,-162.1252,14.1484),SendClientMessage(playerid,COLOR_WHITE,"Spawn Info:You have been spawned at /sfair!");
    }
    return 1;
}
also, the dm im using this for is /minigundm


Re: DM questions - Kevin_Joshen - 08.08.2010

Quote:
Originally Posted by belhot1992
Посмотреть сообщение
If you don't want it to remove the player weapons don't add the ResetPlayerWeapons(playerid); function

did you even read before posting?


Re: DM questions - Ritchie999 - 08.08.2010

Alright i don't know much about the "Respawning in the DM area" but if you want it to remove the guns if you spawn him somewhere else just set up a timer to check every 5-10 seconds if he's in the DM area and if he is he keeps his guns, if he's not it removes his guns.. Something like that