Код:
#include <a_samp>
new FireShot[MAX_PLAYERS];
new gRocketObj[MAX_PLAYERS];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid) && FireShot[playerid] == 0 && newkeys & 4 && !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(11);
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(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]);
}
}
}
No need, you want to set the score for the player, not for the vehicle.