RC Tiger isn't shooting rockets
#1

Код:
new FireShot[MAX_PLAYERS];
new gRocketObj[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(GetPlayerVehicleID(playerid) == 564 && FireShot[playerid] == 0 && KEY_FIRE & newkeys && IsValidObject(gRocketObj[playerid]))   // Only run the code if the object doesn't already exist, otherwise more objects will take up gRocketObj and the previous ones won't be deleted
 	{
  		SetPlayerTime(playerid,0,0);
        new
        	vehicleid = GetPlayerVehicleID(playerid),
         	Float:x,
            Float:y,
            Float:z,
            Float:r,
            Float:dist = 50.0,
            Float:tmpang,
            Float:tmpx,
            Float:tmpy,
            Float:tmpz;

		FireShot[playerid] = 1;
        SetTimerEx("ShotFire", 1000, 0, "i", playerid);
        GetVehiclePos(vehicleid, x, y, z);
        GetVehicleZAngle(vehicleid, r);
        new rand = random(12);
        switch(rand)
        {
        	case 0: gRocketObj[playerid] = CreateObject(18647, x, y, z, 0, 0, r);
            case 1: gRocketObj[playerid] = CreateObject(18648, x, y, z, 0, 0, r);
            case 2: gRocketObj[playerid] = CreateObject(18649, x, y, z, 0, 0, r);
            case 3: gRocketObj[playerid] = CreateObject(18650, x, y, z, 0, 0, r);
            case 4: gRocketObj[playerid] = CreateObject(18651, x, y, z, 0, 0, r);
            case 5: gRocketObj[playerid] = CreateObject(18652, x, y, z, 0, 0, r);
            case 6: gRocketObj[playerid] = CreateObject(18647, x, y, z, 0, 0, r+90);
            case 7: gRocketObj[playerid] = CreateObject(18648, x, y, z, 0, 0, r+90);
            case 8: gRocketObj[playerid] = CreateObject(18649, x, y, z, 0, 0, r+90);
            case 9: gRocketObj[playerid] = CreateObject(18650, x, y, z, 0, 0, r+90);
            case 10: gRocketObj[playerid] = CreateObject(18651, x, y, z, 0, 0, r+90);
            case 11: gRocketObj[playerid] = CreateObject(18652, x, y, z, 0, 0, r+90);
		}
		for(new i;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i))
        	if(i == playerid)continue;
            if(IsPlayerInRangeOfPoint(i, 50.0, x, y, z))
            {
            	GetPlayerPos(i, tmpx, tmpy, tmpz);
                tmpang = (90-atan2(tmpy-y, tmpx-x));
                if(tmpang < 0)tmpang = 360.0+tmpang;
                tmpang = 360.0 - tmpang;
                if(floatabs(tmpang-r) < 5.0)
                {
                	dist = GetPlayerDistanceFromPoint(i, x, y, z);
                }
            }
		}
		MoveObject(gRocketObj[playerid],x + (dist * floatsin(-r, degrees)),y + (dist * floatcos(-r, degrees)),z,100.0);                             // Nice and fast!
	}
}



forward ShotFire(playerid);
public ShotFire(playerid)
{
        FireShot[playerid] = 0;
        return 1;
}

public OnObjectMoved(objectid)
{
        for(new i;i<MAX_PLAYERS;i++)
        {
                if(objectid == gRocketObj[i])
                {
                    new
                    	Float:x,
                     	Float:y,
                      	Float:z;

                    GetObjectPos(gRocketObj[i], x, y, z);
                    CreateExplosion(x, y, z, 11, 3.0);
                    DestroyObject(gRocketObj[i]);
                }
        }
}
What's wrong with dis? :C
Reply


Messages In This Thread
RC Tiger isn't shooting rockets - by VanillaRain - 07.08.2015, 12:12
Re: RC Tiger isn't shooting rockets - by Logofero - 07.08.2015, 12:42
Re: RC Tiger isn't shooting rockets - by VanillaRain - 07.08.2015, 12:51
Re: RC Tiger isn't shooting rockets - by Logofero - 07.08.2015, 12:56
Re: RC Tiger isn't shooting rockets - by Logofero - 07.08.2015, 13:01
Re: RC Tiger isn't shooting rockets - by VanillaRain - 07.08.2015, 13:08
Re: RC Tiger isn't shooting rockets - by Logofero - 07.08.2015, 13:18
Re: RC Tiger isn't shooting rockets - by VanillaRain - 07.08.2015, 13:20
Re: RC Tiger isn't shooting rockets - by MarvinPWN - 07.08.2015, 13:22
Re: RC Tiger isn't shooting rockets - by Logofero - 07.08.2015, 13:23

Forum Jump:


Users browsing this thread: 1 Guest(s)