[+REP]Help (SetVehicleNumberPlate)
#8

Quote:
Originally Posted by Andrei04072
Посмотреть сообщение
Not working
Why did not you declare a local variable new result[256]; as a string and use it as a global? I do not see it, but I see new stringcar[256]; which is generally useless.

PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber[8+1],
}  
public 
IniVehs()
{
    new 
Cacheresult5 mysql_query (handle"SELECT * FROM `vehicles` ORDER BY `vehicles`.`vehicleID` ASC");
    
    new  
// <- Refactoring
         
success 1,
         
x,
         
result[256// Added local varible
    
;    
     for ( new 
icache_get_row_count ( ); != j; ++)
    {
        
cache_get_field_content(i"vehicleID"result); strval(result);
        if(
systemVariables[vehicleCounts][0] + systemVariables[vehicleCounts][1] + systemVariables[vehicleCounts][2] < MAX_VEHICLES
        {
            
cache_get_field_content(i"vehicleModelID"result); vehicleVariables[x][vVehicleModelID] = strval(result);
            
cache_get_field_content(i"vehiclePosX"result); vehicleVariables[x][vVehiclePosition][0] = floatstr(result);
            
cache_get_field_content(i"vehiclePosY"result); vehicleVariables[x][vVehiclePosition][1] = floatstr(result);
            
cache_get_field_content(i"vehiclePosZ"result); vehicleVariables[x][vVehiclePosition][2] = floatstr(result);
            
cache_get_field_content(i"vehiclePosRotation"result); vehicleVariables[x][vVehicleRotation] = floatstr(result);
            
cache_get_field_content(i"vehicleGroup"result); vehicleVariables[x][vVehicleGroup] = strval(result);    
            
cache_get_field_content(i"vehicleGroupRank"result); vehicleVariables[x][vVehicleGroupRank] = strval(result);
            
cache_get_field_content(i"vehicleJob"result); vehicleVariables[x][vVehicleJob] = strval(result);    
            
cache_get_field_content(i"vehicleCol1"result); vehicleVariables[x][vVehicleColour][0] = strval(result);
            
cache_get_field_content(i"vehicleCol2"result); vehicleVariables[x][vVehicleColour][1] = strval(result);
            
cache_get_field_content(i"vehicleNumberPlate"result); format(vehicleVariables[x][vVehicleNumber], 9"%s"result);
            
            if(
vehicleVariables[x][vVehicleColour][0] < 0) {
                
vehicleVariables[x][vVehicleColour][0] = random(126);
            }
            if(
vehicleVariables[x][vVehicleColour][1] < 0) {
                
vehicleVariables[x][vVehicleColour][1] = random(126);
            }
            
format(stringcar256"Group %d",vehicleVariables[x][vVehicleGroup]);
            
vehicleVariables[x][vVehicleScriptID] = CreateVehicle(vehicleVariables[x][vVehicleModelID], vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2], vehicleVariables[x][vVehicleRotation], vehicleVariables[x][vVehicleColour][0], vehicleVariables[x][vVehicleColour][1], 300);
            if(
vehicleVariables[x][vVehicleGroup] >= 1)
            {
                
SetVehicleNumberPlate(xvehicleVariables[x][vVehicleNumber]);
            }
            
systemVariables[vehicleCounts][0]++;
        }
        else 
        {
            
success 0;
            
printf("ERROR: Vehicle limit reached (MODEL %d, VEHICLEID %d, MAXIMUM %d, TYPE STATIC) [01x08]"vehicleVariables[x][vVehicleModelID], xMAX_VEHICLES);
        }
    }
    
cache_delete(result5);
    if(
successprintf("[script] %d vehicles loaded."systemVariables[vehicleCounts][0]);
    return 
1;

Reply


Messages In This Thread
[+REP]Help (SetVehicleNumberPlate) - by Andrei04072 - 27.08.2015, 19:23
Re: [+REP]Help (SetVehicleNumberPlate) - by jlalt - 27.08.2015, 19:35
Re: [+REP]Help (SetVehicleNumberPlate) - by Logofero - 27.08.2015, 19:41
Re: [+REP]Help (SetVehicleNumberPlate) - by Andrei04072 - 27.08.2015, 19:42
Re: [+REP]Help (SetVehicleNumberPlate) - by Andrei04072 - 27.08.2015, 19:49
Re: [+REP]Help (SetVehicleNumberPlate) - by Andrei04072 - 27.08.2015, 19:51
Re: [+REP]Help (SetVehicleNumberPlate) - by Andrei04072 - 27.08.2015, 20:24
Re: [+REP]Help (SetVehicleNumberPlate) - by Logofero - 28.08.2015, 02:20

Forum Jump:


Users browsing this thread: 4 Guest(s)