11.08.2015, 04:08
Quote:
I did not do nothing? look marked in green
Код:
CMD:park(playerid,params[]) { new playerstates = GetPlayerState(playerid); new Float:x, Float:y, Float:z, Float:rot; if(playerstates == PLAYER_STATE_DRIVER) { new storedid = GetPlayerVehicleID(playerid); for(new i=0;i<MAX_PCARS;i++) { if(storedid == PlayerVehicles[playerid][i][pCarID]) { GetVehiclePos(storedid, x, y, z); GetVehicleZAngle(storedid, arot); PlayerVehicles[playerid][i][pCarX] = x; PlayerVehicles[playerid][i][pCarY] = y; PlayerVehicles[playerid][i][pCarZ] = z; PlayerVehicles[playerid][i][pCarRot] = arot; SendClientMessage(playerid, COLOR_GREEN, "You successfully parked the car in your location!"); return 1; } } SendClientMessage(playerid, COLOR_RED, "This is not your car!"); } else { SendClientMessage(playerid, COLOR_RED, "You must be the driver of the car!"); return 1; } return 1; } |
Код:
CMD:park(playerid,params[]) { new playerstates = GetPlayerState(playerid); new Float:x, Float:y, Float:z, Float:rot; if(playerstates == PLAYER_STATE_DRIVER) { new storedid = GetPlayerVehicleID(playerid); for(new i=0;i<MAX_PCARS;i++) { if(storedid == PlayerVehicles[playerid][i][pCarID]) { GetVehiclePos(storedid, x, y, z); GetVehicleZAngle(storedid, arot); PlayerVehicles[playerid][i][pCarX] = x; PlayerVehicles[playerid][i][pCarY] = y; PlayerVehicles[playerid][i][pCarZ] = z; PlayerVehicles[playerid][i][pCarRot] = arot; SendClientMessage(playerid, COLOR_GREEN, "You successfully parked the car in your location!"); return 1; } } SendClientMessage(playerid, COLOR_RED, "This is not your car!"); } else { SendClientMessage(playerid, COLOR_RED, "You must be the driver of the car!"); return 1; } return 1; }
- Different names.
- You should break the loop, instead of returning a value.
- Creating unnecessary variables (you do not need them initialized if they aren't going to be used).
- An unnecessary return.
- Grammar issues.
- Abusing whitespaces, damn...