Reload a vehicle doesn't work
#1

Hello.
When i want to reload a vehicle, it doesn't get respawned, it just dissapears.
I assume it doesnt load correctly, but can't seem to find the problem.
Can someone help me?

This is my code:
PHP Code:

/* ============================================================================= */
stock ReloadVehicle(i)
{
    new 
query1[128]; mysql_format(connectionquery1sizeof(query1), "SELECT * FROM Vehicles WHERE id = '%i'"); mysql_tquery(connectionquery1"LoadVehicle","d",i);
    
printf("Car id %i has been respawned!",i);
    return 
1;
}
/* ============================================================================= */ 
forward LoadVehicle(id);
public 
LoadVehicle(id)
{
      new 
vSAMPID[120],vMYSQLID[120];
      
DestroyVehicle(id);
      
Vehicle[id][vModel] = cache_get_field_content_int(id"vModel");
      
Vehicle[id][vColor1] = cache_get_field_content_int(id"vColor1");
      
Vehicle[id][vColor2] = cache_get_field_content_int(id"vColor2");
      
Vehicle[id][vX] = cache_get_field_content_int(id"vX");
      
Vehicle[id][vY] = cache_get_field_content_int(id"vY");
      
Vehicle[id][vZ] = cache_get_field_content_int(id"vZ");
      
Vehicle[id][vA] = cache_get_field_content_int(id"vA");
      new 
owner[25];
      
cache_get_field_content(id"vOwner"owner);
        
myStrcpy(Vehicle[id][vOwner], owner);
        new 
sampid CreateVehicle(Vehicle[id][vModel], Vehicle[id][vX], Vehicle[id][vY], Vehicle[id][vZ], Vehicle[id][vA], Vehicle[id][vColor1], Vehicle[id][vColor2], -10);
         new 
enginelightsalarmdoorsbonnetbootobjective;
      
GetVehicleParamsEx(sampidenginelightsalarmdoorsbonnetbootobjective);
      
SetVehicleParamsEx(sampid0lightsalarmdoorsbonnetbootobjective);
      
vSAMPID[id] = sampid;
      
vMYSQLID[sampid] = id;
      return 
1;
}
/* ============================================================================= */ 
Reply
#2

you forgot to put ,i in your format so vehicle id wasn't getting wrote on your query....

PHP Code:

/* ============================================================================= */
ReloadVehicle(i)
{
    new
        
query1[128]
    ;
    
mysql_format(connectionquery1sizeof(query1), "SELECT * FROM Vehicles WHERE id = '%i'"i);
    
mysql_tquery(connectionquery1"LoadVehicle","d",i);
    
printf("Car id %i has been respawned!",i);
    return 
1;
}
/* ============================================================================= */
forward LoadVehicle(id);
public 
LoadVehicle(id)
{
      new 
vSAMPID[120],vMYSQLID[120];
      
DestroyVehicle(id);
      
Vehicle[id][vModel] = cache_get_field_content_int(id"vModel");
      
Vehicle[id][vColor1] = cache_get_field_content_int(id"vColor1");
      
Vehicle[id][vColor2] = cache_get_field_content_int(id"vColor2");
      
Vehicle[id][vX] = cache_get_field_content_int(id"vX");
      
Vehicle[id][vY] = cache_get_field_content_int(id"vY");
      
Vehicle[id][vZ] = cache_get_field_content_int(id"vZ");
      
Vehicle[id][vA] = cache_get_field_content_int(id"vA");
      new 
owner[25];
      
cache_get_field_content(id"vOwner"owner);
        
myStrcpy(Vehicle[id][vOwner], owner);
        new 
sampid CreateVehicle(Vehicle[id][vModel], Vehicle[id][vX], Vehicle[id][vY], Vehicle[id][vZ], Vehicle[id][vA], Vehicle[id][vColor1], Vehicle[id][vColor2], -10);
         new 
enginelightsalarmdoorsbonnetbootobjective;
      
GetVehicleParamsEx(sampidenginelightsalarmdoorsbonnetbootobjective);
      
SetVehicleParamsEx(sampid0lightsalarmdoorsbonnetbootobjective);
      
vSAMPID[id] = sampid;
      
vMYSQLID[sampid] = id;
      return 
1;
}
/* ============================================================================= */ 
about the stock read that:
https://sampforum.blast.hk/showthread.php?tid=570635
Reply
#3

Quote:
Originally Posted by jlalt
View Post
you forgot to put ,i in your format so vehicle id wasn't getting wrote on your query....

PHP Code:

/* ============================================================================= */
ReloadVehicle(i)
{
    new
        
query1[128]
    ;
    
mysql_format(connectionquery1sizeof(query1), "SELECT * FROM Vehicles WHERE id = '%i'"i);
    
mysql_tquery(connectionquery1"LoadVehicle","d",i);
    
printf("Car id %i has been respawned!",i);
    return 
1;
}
/* ============================================================================= */
forward LoadVehicle(id);
public 
LoadVehicle(id)
{
      new 
vSAMPID[120],vMYSQLID[120];
      
DestroyVehicle(id);
      
Vehicle[id][vModel] = cache_get_field_content_int(id"vModel");
      
Vehicle[id][vColor1] = cache_get_field_content_int(id"vColor1");
      
Vehicle[id][vColor2] = cache_get_field_content_int(id"vColor2");
      
Vehicle[id][vX] = cache_get_field_content_int(id"vX");
      
Vehicle[id][vY] = cache_get_field_content_int(id"vY");
      
Vehicle[id][vZ] = cache_get_field_content_int(id"vZ");
      
Vehicle[id][vA] = cache_get_field_content_int(id"vA");
      new 
owner[25];
      
cache_get_field_content(id"vOwner"owner);
        
myStrcpy(Vehicle[id][vOwner], owner);
        new 
sampid CreateVehicle(Vehicle[id][vModel], Vehicle[id][vX], Vehicle[id][vY], Vehicle[id][vZ], Vehicle[id][vA], Vehicle[id][vColor1], Vehicle[id][vColor2], -10);
         new 
enginelightsalarmdoorsbonnetbootobjective;
      
GetVehicleParamsEx(sampidenginelightsalarmdoorsbonnetbootobjective);
      
SetVehicleParamsEx(sampid0lightsalarmdoorsbonnetbootobjective);
      
vSAMPID[id] = sampid;
      
vMYSQLID[sampid] = id;
      return 
1;
}
/* ============================================================================= */ 
about the stock read that:
https://sampforum.blast.hk/showthread.php?tid=570635
wtf.

i wanna kick myself in my balls really hard
how could i forget that, XDDDDDDDD.

thanks for ur time, rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)