SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/07/2016, 09:25 AM   #1
justjamie
Huge Clucker
 
Join Date: May 2014
Posts: 424
Reputation: 5
Default Reload a vehicle doesn't work

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;
}
/* ============================================================================= */ 
justjamie is offline   Reply With Quote
Old 26/07/2016, 09:59 AM   #2
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,266
Reputation: 366
Default Re: Reload a vehicle doesn't work

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:
http://forum.sa-mp.com/showthread.php?t=570635
jlalt is offline   Reply With Quote
Old 26/07/2016, 10:01 AM   #3
justjamie
Huge Clucker
 
Join Date: May 2014
Posts: 424
Reputation: 5
Default Re: Reload a vehicle doesn't work

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:
http://forum.sa-mp.com/showthread.php?t=570635
wtf.

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

thanks for ur time, rep
justjamie is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vehicle doesn't reload justjamie Scripting Help 0 25/07/2016 10:51 AM
Vehicle menu doesn't work Majava Scripting Help 3 10/10/2012 12:27 PM
Vehicle Lock doesn't work pantelimonfl Help Archive 5 08/01/2011 01:55 PM
Vehicle menu doesn't work. biltong Help Archive 4 25/01/2010 04:31 PM


All times are GMT. The time now is 12:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.