SA-MP Forums Archive
Help me with the C4 Function - 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)
+--- Thread: Help me with the C4 Function (/showthread.php?tid=512537)



Help me with the C4 Function - Sojo12 - 11.05.2014

I want to add blow bank system, when you be at the right coordinates or near them, you explode but i dont know how, what function should I use or could you post me a fixed code.
Here is my function:
Код:
public ExplodeC4(playerid)
{
  new Float:x, Float:y, Float:z;
  GetObjectPos(C4T, x, y, z);
  DestroyObject(C4T);
  CreateExplosion(x, y, z, 7, 10.0);
  C4T= 0;
  return 1;
}
Thanks in advance.


Re: Help me with the C4 Function - Ciandlah - 11.05.2014

Код:
public ExplodeC4()
{
	 new Float:x, Float:y, Float:z;
	 GetObjectPos(C4T, x, y, z);
	 CreateExplosion(x, y, z, 7, 10.0);
	 DestroyObject(C4T);
	 C4T= 0;
	return 1;
}
Try this, im not sure on what you want, If you said you have a bug with the code. I placed the object after the explosion, you might be trying to get the cords of the object after it gets destroyed.

Also what is the (playerid) for? are you doing the explosion for a player or for everyone?


Re: Help me with the C4 Function - iFiras - 11.05.2014

I think he means to get the right function to use it in the system.
@Sojo You mean a function that allows you to detect the object's coordinates or position and when you blow it, it explodes the specified place like the bank when you are in the right cords or near them.

Am I right?


Re: Help me with the C4 Function - Sojo12 - 11.05.2014

Yea you're right


Re : Help me with the C4 Function - ReD_HunTeR - 11.05.2014

pawn Код:
public ExplodeC4(playerid)
{
   if(IsPlayerInRangeOfPoint(playerid, x, y, z, range)) // fill the X, Y, Z Cordinates, and Range
   {
      new Float:x, Float:y, Float:z;
      GetObjectPos(C4T, x, y, z);
      DestroyObject(C4T);
      CreateExplosion(x, y, z, 7, 10.0);
      C4T= 0;
   }
   return 1;
}
you mean this?, if anything else tell me


Re: Help me with the C4 Function - Ciandlah - 11.05.2014

Код:
public ExplodeC4(playerid)
{
	new Float:x, Float:y, Float:z;
	GetObjectPos(C4T, x, y, z);
	if(IsPlayerInRangeOfPoint(playerid, x, y, z, 4.0))
       {
		DestroyObject(C4T);
		CreateExplosion(x, y, z, 7, 10.0);
		C4T= 0;
	}
        return 1;
}
He wants it like this, So It detects the objects location and If a player is near it.

@Black your one wouldnt ahve worked, he wanted it to detect it like this.


Hopefully this helps you


Re: Help me with the C4 Function - Sojo12 - 11.05.2014

Im sorry guys, nothing worked for me
I think you didn't understand me well.
What I meant is, when you blow a C4 near a bank vault, the bank vault blows and it sends a message to everyone. The problem is I didn't know what function to use to detect if is the C4 in the vault position to blow it.
If the C4 isn't near the position then don't blow the bank vault.
'IsPlayerInRangeOfPoint' didn't work. I don't want to detect if is the player near the C4 in order to blow it. I want to detect if the C4 in the cords or near them or/and in the range in order to explode it and explode the bank vault. Even if he's away of the C4 and he detonates it and it's near the bank vault, the bank vault gets blown.

Maybe you will understand me well here:
What I'm trying to do is blow bank vault system. And to do that, I need the right function but didn't find it.


-I hope you understand.
(I really need this, please help me using this code)


Re: Help me with the C4 Function - Sojo12 - 11.05.2014

^Bump^


Re: Help me with the C4 Function - rickisme - 11.05.2014

Why you don't check C4 in the cords or near bank vault when you plant C4 ?


Re: Help me with the C4 Function - Sojo12 - 11.05.2014

Because I don't have the right function, what function I'll use in your opinion? I think GetObjectPos is not useful because it only depends on the specified position, not less or more. I mean I can't stand on the right position, it's really hard.

GetPlayerPos doesn't include range, near or anything? Is that correct?
It only requires the specified position only, not less or more? Right?