07.08.2016, 21:38
Hello. I have this code and am wondering why the object doesn't delete when I type /garbage. It shows me the message, but the objects still stays in my players hand.
Here is the code that allows players to collect the garbage by pressing "C". I assigned the object to a variable, hoping to delete it with the /garbage command.
Garbage command. It works only when at the back of a Truck Master.
Any help here, it'd be very much appreciated!
Here is the code that allows players to collect the garbage by pressing "C". I assigned the object to a variable, hoping to delete it with the /garbage command.
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(PRESSED(KEY_CROUCH)) { if(Player[playerid][Job] == 2) { if(IsPlayerInRangeOfPoint(playerid, 1.5, -2097.988525, -111.037300, 35.200302)) // { if(Checkpoint[playerid] > -1) { DisablePlayerCheckpoint(playerid); Checkpoint[playerid] = 1; trashObject[playerid] = SetPlayerAttachedObject(playerid, 9, 1265, 5, 0.274000, -0.091999, -0.044000, -79.300033, -95.500007, -16.499979, 0.588000, 0.612000, 0.875000); } } } } return 1; }
Код:
CMD:garbage(playerid, params[]) { if(Player[playerid][LoggedIn] < 1) { ErrorMessage(playerid, "You are not logged in."); return 1; } if(Player[playerid][Job] == 2) { if(Checkpoint[playerid] > -1) { new Float:x, Float:y, Float:z, Float:a, vehicleid; new Float: distance = 50.0; vehicleid = GetClosestVehicle(playerid, distance); GetVehiclePos(vehicleid, x, y, z); GetVehicleZAngle(vehicleid, a); GetOffset(x, y, z, a, 0, -4.5, 0, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 2.0, x, y, z)) { if(trashObject[playerid] > 0) { InformationMessage(playerid, "You throw the garbage into the back of the truck."); DestroyObject(trashObject[playerid]); } else { ErrorMessage(playerid, "You have not picked up the trash yet. Press 'C' at a skip."); return 1; } } } else { ErrorMessage(playerid, "You have not started a trash route."); } } else { ErrorMessage(playerid, "You do not have a job as a Garbage Collector or a Public Transport driver."); } return 1; }