09.02.2014, 15:34
(
Последний раз редактировалось dugi; 12.02.2014 в 17:11.
)
Hello I need help with my own trunk system, I just started with it and I don't know how to detect if vehicle's trunk is already open or not ? I want to make if it's open it will do something and if it's not open and if player want to put something in it it will send him a message here is the code what I tried:
But message appears even if it's open...
Rest of codes that might help you:
Guys I really need help with this :S :S The problem is when I press every option in dialog it bug this system and it says "trunk is already open" even if it's close... Can you help guys I really need help with this
Still need help with this :/
But message appears even if it's open...
pawn Код:
if(listitem == 1) // Put in trunk
{
for(new vid; vid<MAX_VEHICLES; vid++)
{
if(Carinfo[vid][Trunk] == 0)
{
SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to open trunk first.");
return 1;
}
}
}
pawn Код:
enum Car
{
Float:F, // Fuel
VehWin, // Windows
Trunk,
tWeapon1,
tWeapon2,
tWeapon3,
tWeapon4,
tWeapon5,
tWeapon6,
tAmmo1,
tAmmo2,
tAmmo3,
tAmmo4,
tAmmo5,
tAmmo6
};
new Carinfo[MAX_VEHICLES][Car];
pawn Код:
forward Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance);
Float:GetXYBehindCar(vid, &Float:q, &Float:w, Float:distance)
{
new Float:a;
GetVehiclePos(vid, q, w, a);
GetVehicleZAngle(vid, a);
q += (distance * -floatsin(-a, degrees));
w += (distance * -floatcos(-a, degrees));
return a;
}
pawn Код:
if(dialogid == DIALOG_TRUNK)
{
new vehicle = GetPlayerVehicleID(playerid);
new e,l,a,d,b,bo,o;
GetVehicleParamsEx(vehicle,e,l,a,d,b,bo,o);
if(response)
{
if(listitem == 0) // Open the trunk
{
for(new vid; vid<MAX_VEHICLES; vid++)
{
new Float: vx, Float:vy, Float:vz;
GetVehiclePos(vid,vx,vy,vz);
GetXYBehindCar(vid, vx, vy, 1.5);
if(Carinfo[vehicle][Trunk] == 1)
{
SendClientMessage(playerid, -1,"{FF6A22}INFO: {FFFFFF}Trunk is already open.");
return 1;
}
if(IsPlayerInRangeOfPoint(playerid,1.5,vx,vy,vz))
{
Carinfo[vehicle][Trunk] = 1;
SetVehicleParamsEx(vid,e,l,a,d,b,1,o);
return 1;
}
}
}
if(listitem == 1) // Put in trunk
{
if(Carinfo[vehicle][Trunk] == 0)
{
SendClientMessage(playerid, -1,"{FF6A22}INFO: {FFFFFF}You need to open trunk first.");
return 1;
}
}
if(listitem == 2) // Take from trunk
{
if(Carinfo[vehicle][Trunk] == 0)
{
SendClientMessage(playerid, -1,"{FF6A22}INFO: {FFFFFF}You need to open trunk first.");
return 1;
}
}
if(listitem == 3) // Close the trunk
{
for(new vid; vid<MAX_VEHICLES; vid++)
{
new Float: vx, Float:vy, Float:vz;
GetVehiclePos(vid,vx,vy,vz);
GetXYBehindCar(vid, vx, vy, 1.5);
if(Carinfo[vehicle][Trunk] == 0)
{
SendClientMessage(playerid, -1,"{FF6A22}INFO: {FFFFFF}Trunk is already close.");
return 1;
}
if(IsPlayerInRangeOfPoint(playerid,1.5,vx,vy,vz))
{
Carinfo[vehicle][Trunk] = 0;
SetVehicleParamsEx(vid,e,l,a,d,b,0,o);
return 1;
}
}
}
}
return 1;
}