PDA

View Full Version : Help not retain the second car


TMapping
30/11/2016, 10:01 AM
Hello, you can help why not retain the second car

code:
http://pastebin.com/HKmTCi3z

TheRohlikar
30/11/2016, 10:50 AM
" new veh = playerCar1 [ playerid ] ;"

in both stocks

btw. easier and better:

stock savePlayerCar( playerid, veh) {
new query [ 1050] , Float:posi [ 4 ] , Float:hp , Engine , Lights , Alarm, Doors, Bonnet, Boot, Objective;
if ( veh != -1 ) {
GetVehiclePos ( veh , posi [ 0 ] , posi [ 1 ] , posi [ 2 ] ) ;
GetVehicleZAngle ( veh , posi [ 3 ] ) ;
GetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
SetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
GetVehicleHealth ( veh , hp ) ;
format ( query , sizeof ( query ) ,
"UPDATE cars SET \
posX = '%f',\
posY = '%f',\
posZ = '%f',\
posA = '%f',\
lastPosX = '%f',\
lastPosY = '%f',\
lastPosZ = '%f',\
lastPosA = '%f',\
sprogo = %d,\
locked = %d,\
numbers = '%s',\
engine = %d,\
lights = %d,\
hp = '%f',\
rida = '%f',\
gas = %d,\
paintjob = %d,\
color1 = %d,\
color2 = %d, \
vZole = '%d',\
vLSD = '%d',\
vAmfa = '%d',\
akumas = '%d',\
akumohp = '%f'\
WHERE owner = '%s'" ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
vehicleDB [ veh ] [ vSprogo ] , vehicleDB [ veh ] [ vLocked ] ,
vehicleDB [ veh ] [ numeriai ] , Engine , Lights , hp , vehicleDB [ veh ] [ Rida ] , vehicleDB [ veh ] [ gas ] , vehicleDB [ veh ] [ vPaintjob ] , vehicleDB [ veh ] [ vColor ] [ 0 ],
vehicleDB [ veh ] [ vColor ] [ 1 ] ,vehicleDB[veh][vZole],vehicleDB[veh][vLSD],vehicleDB[veh][vAmfa],vehicleDB[veh][akumas],vehicleDB[veh][akumohp], GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
for ( new t = 0; t < 13; t ++ ) {
format ( query , sizeof ( query ) , "UPDATE cars SET tune%d = %d WHERE owner = '%s'" , t , vehicleDB [ veh ] [ vTune ] [ t ] , GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
}
DestroyVehicle ( veh ) ;
}
return 1;
}

Using:

#define MAX_PVEHICLES 10
new playerCar[MAX_PLAYERS][MAX_PVEHICLES];


savePlayerCar(playerid, player[playerid][0]);

TMapping
30/11/2016, 11:16 AM
" new veh = playerCar1 [ playerid ] ;"

in both stocks

btw. easier and better:

stock savePlayerCar( playerid, veh) {
new query [ 1050] , Float:posi [ 4 ] , Float:hp , Engine , Lights , Alarm, Doors, Bonnet, Boot, Objective;
if ( veh != -1 ) {
GetVehiclePos ( veh , posi [ 0 ] , posi [ 1 ] , posi [ 2 ] ) ;
GetVehicleZAngle ( veh , posi [ 3 ] ) ;
GetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
SetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
GetVehicleHealth ( veh , hp ) ;
format ( query , sizeof ( query ) ,
"UPDATE cars SET \
posX = '%f',\
posY = '%f',\
posZ = '%f',\
posA = '%f',\
lastPosX = '%f',\
lastPosY = '%f',\
lastPosZ = '%f',\
lastPosA = '%f',\
sprogo = %d,\
locked = %d,\
numbers = '%s',\
engine = %d,\
lights = %d,\
hp = '%f',\
rida = '%f',\
gas = %d,\
paintjob = %d,\
color1 = %d,\
color2 = %d, \
vZole = '%d',\
vLSD = '%d',\
vAmfa = '%d',\
akumas = '%d',\
akumohp = '%f'\
WHERE owner = '%s'" ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
vehicleDB [ veh ] [ vSprogo ] , vehicleDB [ veh ] [ vLocked ] ,
vehicleDB [ veh ] [ numeriai ] , Engine , Lights , hp , vehicleDB [ veh ] [ Rida ] , vehicleDB [ veh ] [ gas ] , vehicleDB [ veh ] [ vPaintjob ] , vehicleDB [ veh ] [ vColor ] [ 0 ],
vehicleDB [ veh ] [ vColor ] [ 1 ] ,vehicleDB[veh][vZole],vehicleDB[veh][vLSD],vehicleDB[veh][vAmfa],vehicleDB[veh][akumas],vehicleDB[veh][akumohp], GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
for ( new t = 0; t < 13; t ++ ) {
format ( query , sizeof ( query ) , "UPDATE cars SET tune%d = %d WHERE owner = '%s'" , t , vehicleDB [ veh ] [ vTune ] [ t ] , GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
}
DestroyVehicle ( veh ) ;
}
return 1;
}

Using:

#define MAX_PVEHICLES 10
new playerCar[MAX_PLAYERS][MAX_PVEHICLES];


savePlayerCar(playerid, player[playerid][0]);


Once this code is that I do it http://pastebin.com/RdB3vdeh

TheRohlikar
30/11/2016, 11:18 AM
And what do you want now from us ? :D

TMapping
30/11/2016, 11:31 AM
" new veh = playerCar1 [ playerid ] ;"

in both stocks

btw. easier and better:

stock savePlayerCar( playerid, veh) {
new query [ 1050] , Float:posi [ 4 ] , Float:hp , Engine , Lights , Alarm, Doors, Bonnet, Boot, Objective;
if ( veh != -1 ) {
GetVehiclePos ( veh , posi [ 0 ] , posi [ 1 ] , posi [ 2 ] ) ;
GetVehicleZAngle ( veh , posi [ 3 ] ) ;
GetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
SetVehicleParamsEx ( veh , Engine , Lights , Alarm , Doors , Bonnet , Boot , Objective ) ;
GetVehicleHealth ( veh , hp ) ;
format ( query , sizeof ( query ) ,
"UPDATE cars SET \
posX = '%f',\
posY = '%f',\
posZ = '%f',\
posA = '%f',\
lastPosX = '%f',\
lastPosY = '%f',\
lastPosZ = '%f',\
lastPosA = '%f',\
sprogo = %d,\
locked = %d,\
numbers = '%s',\
engine = %d,\
lights = %d,\
hp = '%f',\
rida = '%f',\
gas = %d,\
paintjob = %d,\
color1 = %d,\
color2 = %d, \
vZole = '%d',\
vLSD = '%d',\
vAmfa = '%d',\
akumas = '%d',\
akumohp = '%f'\
WHERE owner = '%s'" ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
posi [ 0 ] , posi [ 1 ] , posi [ 2 ] , posi [ 3 ] ,
vehicleDB [ veh ] [ vSprogo ] , vehicleDB [ veh ] [ vLocked ] ,
vehicleDB [ veh ] [ numeriai ] , Engine , Lights , hp , vehicleDB [ veh ] [ Rida ] , vehicleDB [ veh ] [ gas ] , vehicleDB [ veh ] [ vPaintjob ] , vehicleDB [ veh ] [ vColor ] [ 0 ],
vehicleDB [ veh ] [ vColor ] [ 1 ] ,vehicleDB[veh][vZole],vehicleDB[veh][vLSD],vehicleDB[veh][vAmfa],vehicleDB[veh][akumas],vehicleDB[veh][akumohp], GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
for ( new t = 0; t < 13; t ++ ) {
format ( query , sizeof ( query ) , "UPDATE cars SET tune%d = %d WHERE owner = '%s'" , t , vehicleDB [ veh ] [ vTune ] [ t ] , GetPlayerNameEx ( playerid ) ) ;
mysql_query ( query ) ;
}
DestroyVehicle ( veh ) ;
}
return 1;
}

Using:

#define MAX_PVEHICLES 10
new playerCar[MAX_PLAYERS][MAX_PVEHICLES];


savePlayerCar(playerid, player[playerid][0]);

And what do you want now from us ? :D

I want to keep a second car

TheRohlikar
30/11/2016, 11:35 AM
I edited your stock, it should work. Or fix that mistake (it's written in my post, first line)

You have same line in both stocks.

Means... you take "new veh = playerCar1[playerid]" in both stocks...
means.. everytime same veh.

TMapping
30/11/2016, 01:01 PM
savePlayerCar(playerid, player[playerid][0]);

playerid where there are at variable writing

TMapping
18/04/2019, 10:26 AM
I edited your stock, it should work. Or fix that mistake (it's written in my post, first line)

You have same line in both stocks.

Means... you take "new veh = playerCar1[playerid]" in both stocks...
means.. everytime same veh.

Hello, so how do we load playerCar?