SA-MP Forums

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

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
Trunk Weapon Problem Blake95 Scripting Help 3 30/09/2019 03:46 PM
Weapon Object in the car trunk CoachCarter Scripting Help 0 01/08/2015 08:19 AM
How to place a weapon in trunk? Outcast Scripting Help 3 09/01/2012 12:47 PM


All times are GMT. The time now is 07:06 PM.


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