03.08.2009, 12:29
As you can see in the title i have a problem with the angle of the vehicle after gamemode restart,i have writen a script myself to save the coordinates on the callback onPlayerExitVehicle, it saves the coordinates into arrays and than onGameModeExit it updates the mysql with the new angle, and after restart on onGameModeInit i have a new mysql select for the cars. So the problem is that when i go to my server i find the car in the correct position, but just the angle is not right, where is the problem? There is my scripts:
OnGameModeInit:
OnGameModeExit:
OnPlayerExitVehicle:
Second question: I save the health of the car when the player exits the car, and i set the health of the car on gamemodeinit but the health is still 1000.00 of the car.. even know in database there is 364.4654 (the car was almsot on fire), but it doesn't work, any ideas?
Thank you for you help.
OnGameModeInit:
Code:
//---------------------------------User Cars---------------------------- new ucarsquery[128]; new usercar[12][10]; new ucarsn; format(ucarsquery, sizeof(ucarsquery), "SELECT id,owner,modelid,spawn_x,spawn_y,spawn_z,angle,color1,color2,health,tune,locked FROM `ucars`"); samp_mysql_query(ucarsquery); samp_mysql_store_result(); while(samp_mysql_fetch_row(ucarsquery)) { split(ucarsquery, usercar, '|'); format(playercar[ucarsn][car_uniqueid],256,"%s",usercar[0]); format(playercar[ucarsn][car_owner],256,"%s",usercar[1]); playercar[ucarsn][car_modelid] = strval(usercar[2]); playercar[ucarsn][car_spawnX] = floatstr(usercar[3]); playercar[ucarsn][car_spawnY] = floatstr(usercar[4]); playercar[ucarsn][car_spawnZ] = floatstr(usercar[5]); playercar[ucarsn][car_spawnA] = floatstr(usercar[6]); playercar[ucarsn][car_color1] = strval(usercar[7]); playercar[ucarsn][car_color2] = strval(usercar[8]); playercar[ucarsn][car_health] = floatstr(usercar[9]); playercar[ucarsn][car_tune] = strval(usercar[10]); playercar[ucarsn][car_locked] = strval(usercar[11]); playercar[ucarsn][car_id] = CreateVehicle(playercar[ucarsn][car_modelid],playercar[ucarsn][car_spawnX],playercar[ucarsn][car_spawnY],playercar[ucarsn][car_spawnZ],playercar[ucarsn][car_spawnA],playercar[ucarsn][car_color1],playercar[ucarsn][car_color2],-1); SetVehicleHealth(playercar[ucarsn][car_id],playercar[ucarsn][car_health]); ucarsn++; }
Code:
new ucarsn; new saveucarslocation[256]; new saveucarsinformation[256]; for (ucarsn=0;ucarsn<MAX_CARS; ucarsn++) { format(saveucarslocation, sizeof(saveucarslocation), "UPDATE `ucars` SET `spawn_x` = '%f', `spawn_y` = '%f', `spawn_z` = '%f', `angle` = '%f' WHERE `owner` = '%s';",playercar[ucarsn][car_spawnX],playercar[ucarsn][car_spawnY],playercar[ucarsn][car_spawnZ],playercar[ucarsn][car_spawnA],playercar[ucarsn][car_owner]); format(saveucarsinformation, sizeof(saveucarsinformation), "UPDATE `ucars` SET `color1` = '%i', `color2` = '%i', `health` = '%f', `tune` = '%s', `locked` = '%i' WHERE `owner` = '%s';",playercar[ucarsn][car_color1],playercar[ucarsn][car_color2],playercar[ucarsn][car_health],playercar[ucarsn][car_tune],playercar[ucarsn][car_locked],playercar[ucarsn][car_owner]); samp_mysql_query(saveucarslocation); samp_mysql_query(saveucarsinformation); } return 1; }
Code:
new ucarsn; new Float:x, Float:y, Float:z, Float:a, Float:health; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); GetVehicleHealth(vehicleid, health); for (ucarsn=0;ucarsn<MAX_CARS; ucarsn++) { if (vehicleid == playercar[ucarsn][car_id]) { playercar[ucarsn][car_spawnX] = x; playercar[ucarsn][car_spawnY] = y; playercar[ucarsn][car_spawnZ] = z; playercar[ucarsn][car_spawnA] = a; playercar[ucarsn][car_health] = health; } } return 1; }
Thank you for you help.