Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

value is not setting up

$
0
0
Am trying to make an amml system
when i press Y it says You've run out of missiles, wait a couple of seconds for 29 times;
here i create 29 vehicle and 29 objects and attach them

PHP Code:

    for (new 0!= 29; ++i)
    {
        
AttachObjectToVehicle(g_Object[i], g_Vehicle[i], 0.0000, -1.64000.00000.00000.00000.0000);
    } 

The key press code
PHP Code:

    if(PRESSING(newkeysKEY_YES))
    {
        if(
IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 554)
        {
            new 
vid;
            
vid GetPlayerVehicleID(playerid);
            for(new 
0!= 29; ++j)
            {
                if(
g_Vehicle[j])
                {
                    if(
AAAmmo[vid] > 0)
                    {
                        new 
Float:vXFloat:vYFloat:vZ;
                        new 
Float:XFloat:YFloat:Z;
                        new 
Float:oXFloat:oYFloat:oZ;
                        new 
count 0string[113], name[MAX_PLAYER_NAME];
                        for(new 
0!= 29; ++k)
                        {
                            
GetObjectPos(g_Object[k], oXoYoZ);

                        }
                        
GetVehiclePos(vidvXvYvZ);
                        new 
tname[MAX_PLAYER_NAME];
                        
GetPlayerName(playeridtnamesizeof(tname));
                        foreach(new 
i:Player)
                        {
                            if(
IsPlayerInRangeOfPoint(i250vXvYvZ))
                            {
                                if(
IsPlayerInAnyVehicle(i))
                                {
                                    new 
vid2;
                                    
vid2 GetPlayerVehicleID(i);
                                    if(
GetVehicleModel(vid2) == 520 || GetVehicleModel(vid2) == 525 || GetVehicleModel(vid2) == 476 || GetVehicleModel(vid2) == 487)
                                    {
                                        
GetPlayerName(inamesizeof(name));
                                        
DeletePlayer3DTextLabel(playeridAntiAir[i]);
                                        
GetPlayerPos(iXYZ);
                                        
AAMissile CreateObject(345vXvYvZ000);
                                        new 
time MoveObject(AAMissileXYZ70); //abc
                                        
SetTimerEx("Detonate"time0"ii"playeridAAMissile);
                                        
GameTextForPlayer(i"~n~~n~~n~~n~~n~~n~~n~~r~ANTI-AIR MISSILE APPROACHING"35003);
                                        
PlayerPlaySound(i,1057,0.0,0.0,0.0);
                                        
format(stringsizeof(string), "* Missile approaching %s[%d]!",namei);
                                        
count++;

                                        new 
Float:px,Float:pyFloat:pAngle;
                                        
GetPlayerPos(ipx,py,pAngle);
                                        
GetAAAngle(pxpyoXoYpAngle);
                                        
SetObjectRot(AAObjectoXoYpAngle+90);

                                        new 
P3String[48];
                                        
format(P3Stringsizeof(P3String), "AntiAir Target: %s"name);
                                        
AntiAir[i] = CreatePlayer3DTextLabel(playerid,P3String,0x008080FF,0,0,-1,250.0iINVALID_VEHICLE_ID1);
                                        
printf("%s has pressed 'FIRE' while in the Anti-Air vehicle - %d vehicles detected"tnamecount);
                                        
printf("Missile heading to %s"name);
                                    }
                                }
                            }
                        }
                        if(
count != 0)
                        {
                            
SendClientMessage(playeridCOLOR_SWAGstring);
                            
CanUseAAMissileplayerid ] = false;
                            
AAAmmo[vid]--;
                            if(
AAAmmo[vid] == 0)
                            {
                                
SetTimerEx("ReloadAmmo"5500false"i"playerid);
                            }
                            
format(stringsizeof(string), "* %d vehicles detected - Missile fired at one target!"count);
                            
SendClientMessage(playeridCOLOR_SWAGstring);
                        }
                        else
                        {
                            
SendClientMessage(playeridCOLOR_SWAG"* 0 vehicles detected - No missiles fired!");
                        }
                        
printf("%s has pressed 'FIRE' while in the Anti-Air vehicle - %d vehicles detected"tnamecount);
                    }
                    else 
SendClientMessage(playeridCOLOR_RED"* You've run out of missiles, wait a couple of seconds!");
                }
            }
        }
    } 

On vehicle spawn AMMO should be set to that vehicle should be 4 it too set:
PHP Code:

    if(GetVehicleModel(vehicleid) == 554)
    {
        
AAAmmo[vehicleid] = 5;
    } 

These are the codes.....
Please help me make it working properly...
no missile fired 29 times "You've run out of missiles, wait a couple of seconds" will be told

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>