SA-MP Forums Archive
help with canon - 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: help with canon (/showthread.php?tid=244006)



help with canon - buster_ - 25.03.2011

i am making a canon for a friend, it works like this, it shoots a platform in the air, and if it is up as far as possible the platfor must reset, so i thought of a timer that resets it in about 1 second, cuz the canon is going so fast it will only take that short, but the prob is i don't know how to do it, this is the script so far

Код HTML:
#include <a_samp>

new bullet;

public OnFilterScriptInit()
{
	bullet = CreateObject(3279,268.89947510,1884.10241699,-47.12563324,0.00000000,0.00000000,0.00000000); //object(a51_spottower) (1)
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/boom", true) == 0)
	{
	    MoveObject(bullet, 268.89947510,1884.10241699,-47.12563324, 5000.0);
	    return 1;
	}
	return 0;
}



Re: help with canon - [ProX]BlueFire - 25.03.2011

try this: (untested)
#include <a_samp>
#include <a_players>

Код:
#include <a_players>
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (newkeys & KEY_FIRE)
	{
          SetPlayerAttachedObject;(playerid, 1, 3279, 1, 0, 3, 0, 90, 0, 0, 1, 1, 1);
	}
	return 1;
}
or this:
Код:
#include <a_samp>
#include <a_players>
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))
	
	public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_FIRE))
	{
		new
		SetPlayerAttachedObject;(playerid, 1, 3279, 1, 0, 3, 0, 90, 0, 0, 1, 1, 1);
	}
	return 1;
}



Re: help with canon - Ihsan-Cingisiz - 25.03.2011

Quote:
Originally Posted by buster_
Посмотреть сообщение
i am making a canon for a friend, it works like this, it shoots a platform in the air, and if it is up as far as possible the platfor must reset, so i thought of a timer that resets it in about 1 second, cuz the canon is going so fast it will only take that short, but the prob is i don't know how to do it, this is the script so far

Код HTML:
#include <a_samp>

new bullet;

public OnFilterScriptInit()
{
	bullet = CreateObject(3279,268.89947510,1884.10241699,-47.12563324,0.00000000,0.00000000,0.00000000); //object(a51_spottower) (1)
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/boom", true) == 0)
	{
	    MoveObject(bullet, 268.89947510,1884.10241699,-47.12563324, 5000.0);
	    return 1;
	}
	return 0;
}
Try this:
Код:
#include <a_samp>

new bullet;
forward RemoveBullet();

public OnFilterScriptInit()
{
	bullet = CreateObject(3279,268.89947510,1884.10241699,-47.12563324,0.00000000,0.00000000,0.00000000); //object(a51_spottower) (1)
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/boom", true) == 0)
	{
	    MoveObject(bullet, 268.89947510,1884.10241699,-47.12563324, 5000.0);
	    SetTimer("RemoveBullet", 10000, false);
	    return 1;
	}
	return 0;
}

public RemoveBullet()
{
	DestroyObject(bullet);
}



Re: help with canon - buster_ - 26.03.2011

Quote:
Originally Posted by Ihsan-Cingisiz
Посмотреть сообщение
Try this:
Код:
#include <a_samp>

new bullet;
forward RemoveBullet();

public OnFilterScriptInit()
{
	bullet = CreateObject(3279,268.89947510,1884.10241699,-47.12563324,0.00000000,0.00000000,0.00000000); //object(a51_spottower) (1)
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/boom", true) == 0)
	{
	    MoveObject(bullet, 268.89947510,1884.10241699,-47.12563324, 5000.0);
	    SetTimer("RemoveBullet", 10000, false);
	    return 1;
	}
	return 0;
}

public RemoveBullet()
{
	DestroyObject(bullet);
}
YEP thanx but do u also know how to reset it?
this is really good but, now i need to restart whole FS xD


Re: help with canon - buster_ - 26.03.2011

someone knows?


Re: help with canon - buster_ - 28.03.2011

helleeep


Respuesta: help with canon - [DOG]irinel1996 - 28.04.2011

I think you can reset the position with SetObjectPos.


Re: help with canon - Stigg - 28.04.2011

Try recreating the object after you destroy it.

pawn Код:
public RemoveBullet()
{
    DestroyObject(bullet);
    bullet = CreateObject(3279,268.89947510,1884.10241699,-47.12563324,0.00000000,0.00000000,0.00000000); //object(a51_spottower) (1)
}