29.01.2012, 15:16
Well, I have a trunk system, and the commands are /trunk open/close/check/store/take
Well, the problem is, the players can take weapon from closed trunks. I don't know what am I doing wrong. With /trunk open/close, it works fine and tells the player if the trunk is already closed or not, but it won't return an error message on other commands if the trunk is closed.
This is my code for trunk open/close, which works fine:
Well, this is my "check" command, which doesn't work fine. People can check the content of the trunk even if the trunk is closed, and I don't get it why :S:
[/pawn]
Well, the problem is, the players can take weapon from closed trunks. I don't know what am I doing wrong. With /trunk open/close, it works fine and tells the player if the trunk is already closed or not, but it won't return an error message on other commands if the trunk is closed.
This is my code for trunk open/close, which works fine:
pawn Код:
for(new vid = 0; vid < MAX_VEHICLES; vid++){
if(vid != INVALID_VEHICLE_ID && GetVehicleModel(vid) != 581 && GetVehicleModel(vid) != 509 && GetVehicleModel(vid) != 473 && GetVehicleModel(vid) != 573 && GetVehicleModel(vid) != 521 && GetVehicleModel(vid) != 463 && GetVehicleModel(vid) != 532 && GetVehicleModel(vid) != 461 && GetVehicleModel(vid) != 471 && GetVehicleModel(vid) != 468 && GetVehicleModel(vid) != 581 && GetVehicleModel(vid) != 462 && GetVehicleModel(vid) != 523 && GetVehicleModel(vid) != 481) {
GetVehiclePos(vid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 4, X, Y, Z)){
if (strcmp("open", option, true, 4) == 0){
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(boot == 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] The trunk is already open.");
if(doors == 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] The vehicle is locked.");
SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
format(string, sizeof(string), "opens the trunk of %s.", GetVehicleName(vid));
return PlayerActionMsg(playerid, string);
}
if (strcmp("close", option, true, 5) == 0){
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(boot != 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] The trunk is already closed.");
SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
format(string, sizeof(string), "closes the trunk of %s.", GetVehicleName(vid));
return PlayerActionMsg(playerid, string);
}
}
pawn Код:
if (strcmp("check", option, true, 5) == 0){
new str[80], weapname[20];
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); // << Here is the check, in these 2 lines, which doesn't works correctly for some reason :/
if(boot == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] The trunk is closed.");
SendClientMessage(playerid, COLOR_USAGE, "___________Trunk___________");
if(vInfo[vid][TrunkWeapon1] != 0){
GetWeaponName(vInfo[vid][TrunkWeapon1], weapname, sizeof(weapname))
format(str, sizeof(str), "Weapon Slot 1: %s [%i]", weapname, vInfo[vid][TrunkAmmo1]);
SendClientMessage(playerid, COLOR_USAGE, str);
}
if(vInfo[vid][TrunkWeapon2] != 0){
GetWeaponName(vInfo[vid][TrunkWeapon2], weapname, sizeof(weapname))
format(str, sizeof(str), "Weapon Slot 2: %s [%i]", weapname, vInfo[vid][TrunkAmmo2]);
SendClientMessage(playerid, COLOR_USAGE, str);
}
if(vInfo[vid][TrunkWeapon3] != 0){
GetWeaponName(vInfo[vid][TrunkWeapon3], weapname, sizeof(weapname))
format(str, sizeof(str), "Weapon Slot 3: %s [%i]", weapname, vInfo[vid][TrunkAmmo3]);
SendClientMessage(playerid, COLOR_USAGE, str);
}
if(vInfo[vid][TrunkArmor] != 0){
format(str, sizeof(str), "Armor: Tactical Vest [%f]", vInfo[vid][TrunkArmor]);
SendClientMessage(playerid, COLOR_USAGE, str);
}
SendClientMessage(playerid, COLOR_USAGE, "___________________________");
format(str, sizeof(str), "checks the trunk of %s", GetVehicleName(vid));
return PlayerActionMsg(playerid, str);
}