[+REP]Help (SetVehicleNumberPlate)
#1

There appears to me to car number plate.
PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber,

PHP код:
public IniVehs()
{
    new 
Cacheresult5 mysql_query (handle"SELECT * FROM `vehicles` ORDER BY `vehicles`.`vehicleID` ASC");
    
    new 
success 1;
     
     for ( new 
icache_get_row_count ( ); != j; ++)
    {
        new 
xstringcar[256];
        
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); vehicleVariables[x][vVehicleNumber] = strval(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(xstringcar);
            }
            
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;

Database line
PHP код:
`vehicleNumberPlatevarchar(255NOT NULL DEFAULT 'TEST' 
Reply
#2

PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber,
    
vehicleNumberPlate,

Reply
#3

PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber[8], // fix it > Var type is string
}  
cache_get_field_content(i"vehicleNumberPlate"result); vehicleVariables[x][vVehicleNumber] = result;
// or
cache_get_field_content(i"vehicleNumberPlate"vehicleVariables[x][vVehicleNumber]);
if(
vehicleVariables[x][vVehicleGroup] >= 1)
            {
                
SetVehicleNumberPlate(xvehicleVariables[x][vVehicleNumber]);
            } 
Reply
#4

Quote:
Originally Posted by jlalt
Посмотреть сообщение
PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber,
    
vehicleNumberPlate,

Not working
Reply
#5

Not working
Reply
#6

Quote:
Originally Posted by Logofero
Посмотреть сообщение
PHP код:
enum vehicleE {
    
vVehicleModelID,
    
FloatvVehiclePosition[3],
    
FloatvVehicleRotation,
    
vVehicleGroup,
    
vVehicleJob,
    
vVehicleGroupRank,
    
vVehicleColour[2],
    
vVehicleScriptID,
    
vVehicleNumber[8], // fix it > Var type is string
}  
cache_get_field_content(i"vehicleNumberPlate"result); vehicleVariables[x][vVehicleNumber] = result;
// or
cache_get_field_content(i"vehicleNumberPlate"vehicleVariables[x][vVehicleNumber]);
if(
vehicleVariables[x][vVehicleGroup] >= 1)
            {
                
SetVehicleNumberPlate(xvehicleVariables[x][vVehicleNumber]);
            } 
Not working
Reply
#7

HELP ME PLEASE +rep
Reply
#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


Forum Jump:


Users browsing this thread: 5 Guest(s)