SA-MP Forums Archive
Creating objects and attaching to players - 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: Creating objects and attaching to players (/showthread.php?tid=78017)



Creating objects and attaching to players - dice7 - 16.05.2009

pawn Код:
new turtle[MAX_PLAYERS];
new shark[MAX_PLAYERS];
new dolphin[MAX_PLAYERS];
new chicken[MAX_PLAYERS];
new monkey[MAX_PLAYERS];
new Menu:aminal_menu;
pawn Код:
aminal_menu = CreateMenu("Choose your animal", 1, 50.0, 180.0, 200.0, 200.0);
AddMenuItem(aminal_menu, 0, "Monkey");
AddMenuItem(aminal_menu, 0, "Dolphin");
AddMenuItem(aminal_menu, 0, "Shark");
AddMenuItem(aminal_menu, 0, "Chicken");
AddMenuItem(aminal_menu, 0, "Turtle");
AddMenuItem(aminal_menu, 0, "Human");
pawn Код:
if(strcmp("/animals", cmdtext, true, 10) == 0)
    {
    ShowMenuForPlayer(aminal_menu, playerid);
    return 1;
    }
pawn Код:
new Menu:current2;
  current2 = GetPlayerMenu(playerid);
  if(current2 == aminal_menu)
  {
    switch(row)
    {
      case 0:{
        monkey[playerid] = CreateObject(13667,0.00,0.00,0.00,0.00,0.00,0.00);
SendClientMessage(playerid,COLOR_RED,"You're now a monkey");
AttachObjectToPlayer(playerid,monkey[playerid],0.00,0.00,0.00,0.00,0.00,0.00);
HideMenuForPlayer(aminal_menu, playerid);
      }
      case 1:{
dolphin[playerid] = CreateObject(1609,0.00,0.00,0.00,0.00,0.00,0.00);
SendClientMessage(playerid,COLOR_RED,"You're now a dolphin");
AttachObjectToPlayer(playerid,dolphin[playerid],0.00,0.00,0.00,0.00,0.00,0.00);
HideMenuForPlayer(aminal_menu, playerid);
      }
      case 2:{
shark[playerid] = CreateObject(1608,0.00,0.00,0.00,0.00,0.00,0.00);
SendClientMessage(playerid,COLOR_RED,"You're now a shark");
AttachObjectToPlayer(playerid,shark[playerid],0.00,0.00,0.00,0.00,0.00,0.00);
HideMenuForPlayer(aminal_menu, playerid);
      }
      case 3:{
chicken[playerid] = CreateObject(16776,0.00,0.00,0.00,0.00,0.00,0.00);
SendClientMessage(playerid,COLOR_RED,"You're now a chicken");
AttachObjectToPlayer(playerid,chicken[playerid],0.00,0.00,0.00,0.00,0.00,0.00);
HideMenuForPlayer(aminal_menu, playerid);
      }
      case 4:{
turtle[playerid] = CreateObject(1609,0.00,0.00,0.00,0.00,0.00,0.00);
SendClientMessage(playerid,COLOR_RED,"You're now a turtle");
AttachObjectToPlayer(playerid,turtle[playerid],0.00,0.00,0.00,0.00,0.00,0.00);
HideMenuForPlayer(aminal_menu, playerid);
      }
      case 5:{
DestroyObject(monkey[playerid]);
DestroyObject(dolphin[playerid]);
DestroyObject(shark[playerid]);
DestroyObject(chicken[playerid]);
DestroyObject(turtle[playerid]);
HideMenuForPlayer(aminal_menu, playerid);

      }
    }
  }
The menu and everything works, just the object doesn't create or attach to player. Something of these two.
Please help


Re: Creating objects and attaching to players - yom - 16.05.2009

Look carefully the definition of AttachObjectToPlayer.


Re: Creating objects and attaching to players - Weirdosport - 16.05.2009

AttachObjectToPlayer(OBJECT, PLAYER, ....

EDIT: RAWRRR Orb got there first, was busy looking to see difference between this and SeaSuits >.>


Re: Creating objects and attaching to players - dice7 - 16.05.2009

Why didn't I then got a tag mismatch or something