View Single Post
Old 24/02/2020, 06:20 AM   #1
Blake95
Little Clucker
 
Join Date: Nov 2016
Posts: 27
Reputation: 2
Default Weapon trunk bug, shut down server

Hi all!

I nees help this script, i put weapon to trunk and the server shut down.

Code:
  this::AddWeaponToTrunk(playerid, vehicleid, slot, weapon, ammo)
{
    vehicle_trunk_data[vehicleid][slot][data_id] = cache_insert_id();
    vehicle_trunk_data[vehicleid][slot][veh_wep] = weapon;
    vehicle_trunk_data[vehicleid][slot][veh_ammo] = ammo;
    vehicle_trunk_data[vehicleid][slot][is_exist] = true;
    vehicle_trunk_data[vehicleid][slot][veh_id] = VehicleInfo[vehicleid][eVehicleDBID];

	for(new i = 0; i < 6; i++) vehicle_trunk_data[vehicleid][slot][wep_offset][i] = 0.0;

	new Float: player_pos[3];
	GetPlayerPos(playerid, player_pos[0], player_pos[1], player_pos[2]);
    PlayerInfo[playerid][pEditingObject] = 3;
    SetPVarInt(playerid, "getVehicleID", vehicleid);
    SetPVarInt(playerid, "getSlot", slot);

    vehicle_trunk_data[vehicleid][slot][temp_object] = CreateDynamicObject(ReturnWeaponsModel(weapon), player_pos[0], player_pos[1], player_pos[2], 0, 0, 0);
	EditDynamicObject(playerid, vehicle_trunk_data[vehicleid][slot][temp_object]);
    SendClientMessage(playerid, COLOR_LIGHTRED, "[ ! ]{FFFFFF} Tarthatod {FFFF00}W{FFFFFF} a szerkeszt鳠k��ni mozgat᳡hoz.");

	PlayerInfo[playerid][pWeaponsAmmo][ ReturnWeaponIDSlot(weapon) ] = 0;
	PlayerInfo[playerid][pWeapons][ ReturnWeaponIDSlot(weapon) ] = 0;
	RemovePlayerWeapon(playerid, weapon);

    sendMessage(playerid, -1, "{FFFF00} TᲯltᬠegy %s-t. JᲭ: %s.", ReturnWeaponName(weapon), ReturnVehicleName(vehicleid));
	return 1;
}
Code:
.   new
		            vehicleid = GetPVarInt(playerid, "getVehicleID" ),
		            slot = GetPVarInt(playerid, "getSlot" ),
					Float:ofx, Float:ofy,
					Float:ofz, Float:ofaz,
					Float: getPoint[3],
					Float:getDistance,
					insert[512],
		            Float:finalx, Float:finaly,
			    	Float:px, Float:py, Float:pz, Float:roz
				;

				GetVehiclePartPos(vehicleid, VEHICLE_PART_CHASSIS, getPoint[0], getPoint[1], getPoint[2]);
		        getDistance = XB_GetDistanceBetweenTPoints(x, y, z, getPoint[0], getPoint[1], getPoint[2]);
				if(response == EDIT_RESPONSE_CANCEL)
				{
				    AttachDynamicObjectToVehicle( vehicle_trunk_data[vehicleid][slot][temp_object] , vehicleid, 0, 0, 0, 0, 0, 0);
				    SendClientMessage(playerid, COLOR_LIGHTRED, "INFO: A fegyvert a csomagtart󢡠kell rakni! Az alap poz�󲡠kerlt.");

				    for(new i = 0; i < 6; i ++) vehicle_trunk_data[vehicleid][slot][wep_offset][i] = 0.0;

					mysql_format(this, insert, sizeof(insert), "UPDATE vehicle_trunk SET offsetX = 0.0, offsetY = 0.0, offsetZ = 0.0, rotX = 0.0, rotY = 0.0, rotZ = 0.0 WHERE id = %i",
						vehicle_trunk_data[vehicleid][slot][data_id]);

					mysql_tquery(this, insert);
					DeletePVar(playerid, "getVehicleID");
					DeletePVar(playerid, "getSlot");
					PlayerInfo[playerid][pEditingObject] = 0;
					return true;
				}
				if(response == EDIT_RESPONSE_FINAL)
				{
				    if(getDistance > 1.8)
				    {
					    AttachDynamicObjectToVehicle( vehicle_trunk_data[vehicleid][slot][temp_object] , vehicleid, 0, 0, 0, 0, 0, 0);
					    SendClientMessage(playerid, COLOR_YELLOWEX, "INFӺ A fegyvert a csomagtart󢡠kell rakni! Az alap poz�󲡠kerlt.");

					    for(new i = 0; i < 6; i ++) vehicle_trunk_data[vehicleid][slot][wep_offset][i] = 0.0;

						mysql_format(this, insert, sizeof(insert), "UPDATE vehicle_trunk SET offsetX = 0.0, offsetY = 0.0, offsetZ = 0.0, rotX = 0.0, rotY = 0.0, rotZ = 0.0 WHERE id = %i",
							vehicle_trunk_data[vehicleid][slot][data_id]);

						mysql_tquery(this, insert);
				    }
				    else
				    {
					    GetVehiclePos(vehicleid, px, py, pz);
					    GetVehicleZAngle(vehicleid, roz);
					    ofx = x-px;
					    ofy = y-py;
					    ofz = z-pz;
					    ofaz = rz-roz;
					    finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees);
					    finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees);


					    AttachDynamicObjectToVehicle( vehicle_trunk_data[vehicleid][slot][temp_object] , vehicleid, finalx, finaly, ofz, rx, ry, ofaz);
						mysql_format(this, insert, sizeof(insert), "UPDATE vehicle_trunk SET offsetX = %f, offsetY = %f, offsetZ = %f, rotX = %f, rotY = %f, rotZ = %f WHERE id = %i",
						finalx, finaly, ofz, rx, ry, ofaz, vehicle_trunk_data[vehicleid][slot][data_id]);

					 	vehicle_trunk_data[vehicleid][slot][wep_offset][0] = finalx;
						vehicle_trunk_data[vehicleid][slot][wep_offset][1] = finaly;
						vehicle_trunk_data[vehicleid][slot][wep_offset][2] = ofz;
						vehicle_trunk_data[vehicleid][slot][wep_offset][3] = rx;
						vehicle_trunk_data[vehicleid][slot][wep_offset][4] = ry;
						vehicle_trunk_data[vehicleid][slot][wep_offset][5] = ofaz;

				    }
					DeletePVar(playerid, "getVehicleID");
					DeletePVar(playerid, "getSlot");
					PlayerInfo[playerid][pEditingObject] = 0;
					SendClientMessage(playerid, COLOR_LIGHTRED, "Hasznᬤ a /takegun parancsot, hogy a fegyvert hẢ󬯣somagtart󢳬 vedd ki.");
					SendClientMessage(playerid, COLOR_LIGHTRED, "NOTE: K�� kell lenned a fizikai modellhez.");
					return true;
				}
				if(response == EDIT_RESPONSE_UPDATE)
				{
				    if(getDistance > 1.8)
				    {
				        SendClientMessage(playerid, COLOR_LIGHTRED, "Az objektum tl messze van a csomagtart󴳬!");
				    }
				}
			}
Blake95 is offline   Reply With Quote