Scripted Smoke
#1

Guys I scripted some smoke quickly for the army in my script, but timers have been a pain in the ass.

I want it so it disappears six seconds after you plant it, but I can't get it to work code:

Код:
  GetPlayerPos(playerid, cx, cy, cz);
      ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
      CreateObject(2780, cx, cy-3, cz, 90, 90, 90);
	  DestroyObject(2780); // There shall be a timer before this I made one but it didn't work so I deleted it here
I only showed the vital part of the good as the rest won't matter.


If you can help me thanks,

Jeroen.
Reply
#2

pawn Код:
forward DestroySmoke();
new SmokeObject;
pawn Код:
GetPlayerPos(playerid, cx, cy, cz);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
SmokeObject = CreateObject(2780, cx, cy-3, cz, 90, 90, 90);
SetTimer("DestorySmoke", 6000, false);
pawn Код:
public DestorySmoke()
{
DestoryObject(SmokeObject);
return 1;
}
Reply
#3

Quote:
Originally Posted by Conroy
pawn Код:
forward DestroySmoke();
new SmokeObject;
pawn Код:
GetPlayerPos(playerid, cx, cy, cz);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
SmokeObject = CreateObject(2780, cx, cy-3, cz, 90, 90, 90);
SetTimer("DestorySmoke", 6000, false);
pawn Код:
public DestorySmoke()
{
DestoryObject(SmokeObject);
return 1;
}
Thanks for your help, I really need to learn timers better lol.
Reply
#4

I don't think it's your timers that were wrong, it was the fact that you need to add your object to a variable, in this case 'SmokeObject'. This is only used to alter the objects properties, like move, delete, attach to player etc etc.
Reply
#5

Lol and lol.

@Conroy, and what would happen if two objects are created?

pawn Код:
GetPlayerPos(playerid, cx, cy, cz);
      ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
      SetTimerEx("DestroySmoke",6000,false,"i",CreateObject(2780, cx, cy-3, cz, 90, 90, 90));
     
      public DestroySmoke(smokeid) return DestroyObject(smokeid);
Reply
#6

If your allowing the player to plant smoke,
Then add you would do it like this:

[code=Edited from Conroy]
forward DestroySmoke(playerid);
new SmokeObject[MAX_PLAYERS];[/code]

[code=Edited from Conroy]
GetPlayerPos(playerid, cx, cy, cz);
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
SmokeObject[playerid] = CreateObject(2780, cx, cy-3, cz, 90, 90, 90);
SetTimerEx("DestroySmoke", 6000, 0, "i", playerid);[/code]

[code=Edited from Conroy]public DestorySmoke(playerid)
{
DestoryObject(SmokeObject[playerid]);
return 1;
}[/code]
Reply
#7

True, I use this for a fire system though so that's why I put it this way. For player use then yeah you would do it either way above.
Reply
#8

@Joe Torran C, please look at my example. You can't make it better than that. You only need to pass objectid parameter, so it's compeltly useless to open any other memory cells (like you did).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)