DM Problem
#1

Hi,

Well, here is problem when player dies I want to respawn again in DM.
Codes:
Код:
#include <a_samp>
#include <zcmd>

new InDM[MAX_PLAYERS];
new DmID[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
        InDM[playerid] = 0;
        DmID[playerid] = 0;
}

public OnPlayerDeath(playerid, killerid)
{
		InDM[playerid] = 1;
        return 1;
}

public OnPlayerSpawn(playerid)
{

    if(InDM[playerid] == 1 && DmID[playerid] == 1)
    {
        SetPlayerInterior(playerid, 1);
        SetPlayerPos(playerid, 1412.639892, -1.787510, 1000.924377);
        SetPlayerVirtualWorld(playerid, 1);

    }
    else if(InDM[playerid] == 1 && DmID[playerid] == 2)
    {
        SetPlayerInterior(playerid, 10);
        SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
        SetPlayerVirtualWorld(playerid, 1);

    }
    else if(InDM[playerid] == 1 && DmID[playerid] == 3)
    {
	    SetPlayerInterior(playerid, 3);
	    SetPlayerPos(playerid, 288.745971, 169.350997, 1007.171875);
	    SetPlayerVirtualWorld(playerid, 1);

    }
    else if(InDM[playerid] == 1 && DmID[playerid] == 4)
    {
	    SetPlayerInterior(playerid, 3);
	    SetPlayerPos(playerid, -2640.762939, 1406.682006, 906.460937);
	    SetPlayerVirtualWorld(playerid, 1);

    }
    return 1;
}

CMD:dm(playerid, params[])
{
        InDM[playerid] = 1;
        DmID[playerid] = 1;

        SendClientMessage(playerid, -1, "{66FF66}Welcome to Running Weapons DM {BABABA}(SawnOff - Uzi)");
        SetPlayerInterior(playerid, 1);
        SetPlayerPos(playerid, 1412.639892, -1.787510, 1000.924377);
        SetPlayerVirtualWorld(playerid, 1);

        ResetPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, 26, 100000);
        GivePlayerWeapon(playerid, 28, 100000);

        new str[36+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "{FFFFFF}%s {BABABA}(ID: %d) has gone to /rw", name, playerid);
        SendClientMessageToAll(-1, str);
        return 1;
}

CMD:dm1(playerid, params[])
{
        InDM[playerid] = 1;
        DmID[playerid] = 2;

        SendClientMessage(playerid, -1, "{66FF66}Welcome to Running Weapons DM 2 {BABABA}(SawnOff - Tec-9)");
        SetPlayerInterior(playerid, 10);
        SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
        SetPlayerVirtualWorld(playerid, 1);

        ResetPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, 26, 100000);
        GivePlayerWeapon(playerid, 32, 100000);

        new str[36+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "{FFFFFF}%s {BABABA}(ID: %d) has gone to /rw2", name, playerid);
        SendClientMessageToAll(-1, str);
        return 1;
}

CMD:dm2(playerid, params[])
{
        InDM[playerid] = 1;
        DmID[playerid] = 3;

        SendClientMessage(playerid, -1, "{66FF66}Welcome to Walking Weapons DM {BABABA}(Deagle - Shotgun)");
        SetPlayerInterior(playerid, 3);
        SetPlayerPos(playerid, 288.745971, 169.350997, 1007.171875);
        SetPlayerVirtualWorld(playerid, 1);

        ResetPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, 24, 100000);
        GivePlayerWeapon(playerid, 25, 100000);

        new str[36+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "{FFFFFF}%s {BABABA}(ID: %d) has gone to /ww", name, playerid);
        SendClientMessageToAll(-1, str);
        return 1;
}

CMD:dm3(playerid, params[])
{
        InDM[playerid] = 1;
        DmID[playerid] = 4;

        SendClientMessage(playerid, -1, "{66FF66}Welcome to Walking Weapons DM 2 {BABABA}(Shotgun - Sniper)");
        SetPlayerInterior(playerid, 3);
        SetPlayerPos(playerid, -2640.762939, 1406.682006, 906.460937);
        SetPlayerVirtualWorld(playerid, 1);

        ResetPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, 25, 100000);
        GivePlayerWeapon(playerid, 34, 100000);

        new str[36+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(str, sizeof(str), "{FFFFFF}%s {BABABA}(ID: %d) has gone to /ww2", name, playerid);
        SendClientMessageToAll(-1, str);
        return 1;
}

CMD:qdm(playerid, params[])
{
        if (InDM[playerid] == 1)
        {
	        SetPlayerVirtualWorld(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SpawnPlayer(playerid);
	        InDM[playerid] = 0;
	        DmID[playerid] = 0;
    	}
        else
        {
        	return SendClientMessage(playerid, -1, "{FFFFFF}You are not in a DM");
        }
    	return 1;
}
Thanks.
Reply
#2

Try this:
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
InDM[playerid] == 1)
    {
         if(
DmID[playerid] == 1)
         {
             
SetPlayerInterior(playerid1);
             
SetPlayerPos(playerid1412.639892, -1.7875101000.924377);
             
SetPlayerVirtualWorld(playerid1);
         }
         else if(
DmID[playerid] == 2)
         {
             
SetPlayerInterior(playerid10);
             
SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
             
SetPlayerVirtualWorld(playerid1);
         }
         else if(
DmID[playerid] == 3)
         {
          
SetPlayerInterior(playerid3);
          
SetPlayerPos(playerid288.745971169.3509971007.171875);
          
SetPlayerVirtualWorld(playerid1);
         }
         else
         {
           
SetPlayerInterior(playerid3);
           
SetPlayerPos(playerid, -2640.7629391406.682006906.460937);
           
SetPlayerVirtualWorld(playerid1);
          }
    }
    return 
1;

Reply
#3

Same problem.
Reply
#4

if(InDM[playerid] == 1 && DmID[playerid] == 1)

Zasto koristis funkcije da poseduje oba callbacka?

Simple fix, if(InDM[playerid] == 1 || DmID[playerid] == 1) Instead of ( && )

Checks if he has any of your variables, there tho he will spawn on death.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)