AttachObjectToPlayer doesnt work for me
#1

new chicken;

chicken = CreateObject(16776, -362.0141, 81.74512, 45, 0, 0, 0);

pawn Код:
if(!strcmp(cmdtext, "/chickendm", true))
        {
        if(DMZone[playerid] == 1) return SendClientMessage(playerid,COLOR_RED, "ERROR: You can't use this command in DM!");
        DMZone[playerid] = 1;
        SetPlayerWorldBounds(playerid, -280.269, -677.3168, 350.3363, -105.1009);
        ResetPlayerWeapons(playerid);
        new var5 = random(6);
        if(!var5)
        {
            SetPlayerPos(playerid, -607.2495, 128.4566, 50);
            SetPlayerFacingAngle(playerid, 247.9705);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 1)
        {
            SetPlayerPos(playerid, -385.3699, 81.74512, 55);
            SetPlayerFacingAngle(playerid, 329.4379);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 2)
        {
            SetPlayerPos(playerid, -560.538, 70.06725, 55);
            SetPlayerFacingAngle(playerid, 46.832);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 3)
        {
            SetPlayerPos(playerid, -385.3699, 81.74512, 55);
            SetPlayerFacingAngle(playerid, 121.7194);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 4)
        {
             SetPlayerPos(playerid, -560.538, 70.06725, 55);
            SetPlayerFacingAngle(playerid, 196.27);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 5)
        {
            SetPlayerPos(playerid, -513.8265, 116.7788, 50);
            SetPlayerFacingAngle(playerid, 255.2006);
            SetCameraBehindPlayer(playerid);
        }
        SetPlayerInterior(playerid, 0);
        AttachObjectToPlayer( chicken, playerid, 1.5, 0.5, 0, 0, 1.5, 2 );
        SendClientMessage(playerid, 0x0000FFAA, "You have been teleported to the Chicken DM");
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 30, 1000);
        GameTextForPlayer(playerid, "Chicken DM", 6000, 6);
        GivePlayerWeapon(playerid, 25, 1000);
        GivePlayerWeapon(playerid, 29, 1000);
        return 1;
    }
Reply
#2

ok i fixed the problem

but somehow it only works for 1 player
Reply
#3

help :S
Reply
#4

No need to bump your own topic. And from this code i guess it will work for everyone who uses /chickendm command.
Reply
#5

Quote:
Originally Posted by HydraX [hydrablast.smfnew.com
]
ok i fixed the problem

but somehow it only works for 1 player
The reason being that there is only 1 object . Use create object when the player joins then destroy it when they leave .

E.G.
pawn Код:
new ChickenOB[MAX_PLAYERS];
new ChickenDM[MAX_PLAYERS];
pawn Код:
if(!strcmp(cmdtext, "/chickendm", true))
        {
        if(DMZone[playerid] == 1) return SendClientMessage(playerid,COLOR_RED, "ERROR: You can't use this command in DM!");
        DMZone[playerid] = 1;
        SetPlayerWorldBounds(playerid, -280.269, -677.3168, 350.3363, -105.1009);
        ResetPlayerWeapons(playerid);
        new var5 = random(6);
        if(!var5)
        {
            SetPlayerPos(playerid, -607.2495, 128.4566, 50);
            SetPlayerFacingAngle(playerid, 247.9705);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 1)
        {
            SetPlayerPos(playerid, -385.3699, 81.74512, 55);
            SetPlayerFacingAngle(playerid, 329.4379);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 2)
        {
            SetPlayerPos(playerid, -560.538, 70.06725, 55);
            SetPlayerFacingAngle(playerid, 46.832);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 3)
        {
            SetPlayerPos(playerid, -385.3699, 81.74512, 55);
            SetPlayerFacingAngle(playerid, 121.7194);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 4)
        {
             SetPlayerPos(playerid, -560.538, 70.06725, 55);
            SetPlayerFacingAngle(playerid, 196.27);
            SetCameraBehindPlayer(playerid);
        }
        if(var5 == 5)
        {
            SetPlayerPos(playerid, -513.8265, 116.7788, 50);
            SetPlayerFacingAngle(playerid, 255.2006);
            SetCameraBehindPlayer(playerid);
        }
        SetPlayerInterior(playerid, 0);
        ChickenOB[playerid] = CreateObject(16776, -362.0141, 81.74512, 45, 0, 0, 0);
        AttachObjectToPlayer(ChickenOB[playerid], playerid, 1.5, 0.5, 0, 0, 1.5, 2 );
        SendClientMessage(playerid, 0x0000FFAA, "You have been teleported to the Chicken DM");
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 30, 1000);
        GameTextForPlayer(playerid, "Chicken DM", 6000, 6);
        GivePlayerWeapon(playerid, 25, 1000);
        GivePlayerWeapon(playerid, 29, 1000);
        ChickenDM[playerid] = 1;
        return 1;
    }
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  if(ChickenDM[playerid] == 1)
  {
    DestroyObject(ChickenOB[playerid]);
  }
  return 1;
}
Reply
#6

oh thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)