SA-MP Forums

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

Reply
 
Thread Tools Display Modes
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
Old 24/02/2020, 09:10 AM   #2
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 236
Reputation: 49
Default Re: Weapon trunk bug, shut down server

Compile the script with -d3( open, or create pawn.cfg in your pawno folder, inside of it write -d3 ). Download crashdetect, and run server.exe, put weapon in trunk and once your server crashes, you will see in server.log the exact line that is causing the server to crash.
__________________
Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar is offline   Reply With Quote
Old 24/02/2020, 09:18 AM   #3
Blake95
Little Clucker
 
Join Date: Nov 2016
Posts: 27
Reputation: 2
Default Re: Weapon trunk bug, shut down server

I cant see crashes in server log , but i have crashdetect.
Blake95 is offline   Reply With Quote
Old 24/02/2020, 09:33 AM   #4
jasperschellekens
Gangsta
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 994
Reputation: 92
Default Re: Weapon trunk bug, shut down server

And are you also compiling in debug mode like ShadowMortar said?
It will tell you what is going on in the server log.
__________________
Coming soon (6-1-2020):

Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Official Live Beta Release Date: 1st of June, 2020
Discord - Website
jasperschellekens is online now   Reply With Quote
Old 24/02/2020, 04:58 PM   #5
Blake95
Little Clucker
 
Join Date: Nov 2016
Posts: 27
Reputation: 2
Default Re: Weapon trunk bug, shut down server

Yes i comple debug mode.. But server crashes.. so i place the weapon, and server running, but crashed.. i cant write i cant join the server...
Blake95 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
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 10:28 AM.


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