09.02.2019, 00:32
Never check if floats are equal to a specific value! Always <= or >=
Why bother making extra variables and assignments here? This can be useful when you have more code but this is just a short bit of code why bother?
Where is OnFilterScriptExit() with clean up code?
How do you know that will work for all vehicles and look good?
Alright that is nice but what about checking if the player is a driver?
Always define your dialog id's! That way if there is a collision all you have to do is change the id once.
Critical issue here.
If you have the dialog open and you exit a vehicle that object will be destroyed. Now if someone creates an object for any reason and it takes that id and it so happens the player was put back into a vehicle then there is the potential for objects to be deleted.
Always avoid creating player textdraws when a player connects. Reason being, maybe they disconnect. Maybe they fail to log in. What is the point of creating textdraws that majority of the time probably won't be used? Create when a player types a command or when a player actually logs in (gamemodes).
Code:
if (yc == 0.0 || xc == 0.0) { if(yc == 0 && xc > 0) angle = 0.0; else if(yc == 0 && xc < 0) angle = 180.0; else if(yc > 0 && xc == 0) angle = 90.0; else if(yc < 0 && xc == 0) angle = 270.0; else if(yc == 0 && xc == 0) angle = 0.0; }
Code:
pPos[0] = NavData[pNavID[playerid]][NAV_X]; pPos[1] = NavData[pNavID[playerid]][NAV_Y]; pPos[2] = NavData[pNavID[playerid]][NAV_Z];
How do you know that will work for all vehicles and look good?
Code:
AttachObjectToVehicle(ok[playerid], GetPlayerVehicleID(playerid), 0.000000, 0.000000, 1.399998, 0.000000, 90.0, rot + 180);
Code:
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{FF0000}<!> You must be in a vehicle to use navigation!");
Code:
ShowPlayerDialog(playerid, 112, DIALOG_STYLE_LIST, "[Navigation] Locations", string, "Select", "Close");
Code:
if(IsValidObject(ok[playerid])) DestroyObject(ok[playerid]);
Always avoid creating player textdraws when a player connects. Reason being, maybe they disconnect. Maybe they fail to log in. What is the point of creating textdraws that majority of the time probably won't be used? Create when a player types a command or when a player actually logs in (gamemodes).
Code:
public OnPlayerConnect(playerid) { NAVpTD[playerid] = CreatePlayerTextDraw(playerid, 405.724487, 415.166564, "Distance Left: ~y~0000.00m"); PlayerTextDrawLetterSize(playerid, NAVpTD[playerid], 0.179326, 1.109999); PlayerTextDrawAlignment(playerid, NAVpTD[playerid], 1); PlayerTextDrawColor(playerid, NAVpTD[playerid], -1); PlayerTextDrawSetShadow(playerid, NAVpTD[playerid], 0); PlayerTextDrawSetOutline(playerid, NAVpTD[playerid], 0); PlayerTextDrawBackgroundColor(playerid, NAVpTD[playerid], 255); PlayerTextDrawFont(playerid, NAVpTD[playerid], 2); PlayerTextDrawSetProportional(playerid, NAVpTD[playerid], 1); PlayerTextDrawSetShadow(playerid, NAVpTD[playerid], 0); return 1; }