SA-MP Forums Archive
the logic of a value in a variable - 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)
+--- Thread: the logic of a value in a variable (/showthread.php?tid=664134)



the logic of a value in a variable - kloning1 - 20.02.2019

hi, how do I do it, I want to make a static vehicle with the contents of the variable as I wish.
I found some logic, but in my opinion it was lacking, so I asked here.

a little example of the script that I made

PHP код:
new vehstaticspawn[99];
enum E_VEHICLE_STATIC
{
    
vehstid,
    
vehstmodel,
    
vehstposx,
    
vehstposy,
    
vehstposz
}
new 
Vehstatic[MAX_VEHICLE][E_VEHICLE_STATIC];
public 
LoadVehicleStatic()
{
    if(
cache_num_rows())
    {
        for(new 
1cache_num_rows(); a++)
        {
            
cache_get_index_int(a,0,Vehstatic[a][vehstid]);
            
cache_get_index_int(a,1,Vehstatic[a][vehstmodel]);
            
cache_get_index_float(a,2,Vehstatic[a][vehstposx]);
            
cache_get_index_float(a,3,Vehstatic[a][vehstposy]);
            
cache_get_index_float(a,4,Vehstatic[a][vehstposz]);
            
cache_get_index_float(a,5,Vehstatic[a][vehstposa]);
            
vehstaticspawn[a] = AddStaticVehicle(Vehstatic[a][vehstmodel], Vehstatic[a][vehstposx], Vehstatic[a][vehstposy], Vehstatic[a][vehstposa], 01);
        }
    }

well I want to ask, can 99 on the vehstaticspawn variable be changed according to the row in the database?
and at MAX_VEHICLE can I change it according to the row in the database?

just a thought, the usefulness of changing variable content might make my gamemode more efficient

I'm sorry, I use g00gle Translate, if there is a wrong word sorry, thank you


Re: the logic of a value in a variable - Calisthenics - 20.02.2019

There are already 5 items with size of MAX_VEHICLES, what is the problem with one more?

There is y_malloc include but you should not care this much about such things. They say premature optimization is the root of all evil.


Re: the logic of a value in a variable - kloning1 - 20.02.2019

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
There are already 5 items with size of MAX_VEHICLES, what is the problem with one more?

There is y_malloc include but you should not care this much about such things. They say premature optimization is the root of all evil.
umm, thank you for the answer, I really appreciate it