help with canon
#1

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;
}
Reply
#2

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;
}
Reply
#3

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);
}
Reply
#4

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
Reply
#5

someone knows?
Reply
#6

helleeep
Reply
#7

I think you can reset the position with SetObjectPos.
Reply
#8

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)
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)