







for(new i=0 ; i<MAX_PLAYERS ; i++)
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue; //no need to loop through players not connected
new pname[MAX_PLAYER_NAME], string[120];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s is now one of our mechanics in San Andreas!", pname);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT ) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!");
if(mechjob[playerid] == 1)
{//code
else if(GetPlayerState(id) == PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,COLOR_MECHANIC, "That player is not in a vehicle!");
else if(GetPlayerState(id) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "That player is not driving a vehicle!");
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command!");
else if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command!");
if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
{
if(vhealth == 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");
if(vhealth > 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");
if(vhealth >= 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");// >= for bigger than or equal to
GetPlayerName(id, pName, sizeof(pName));
RepairVehicle(GetPlayerVehicleID(id));
format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
SendClientMessage(playerid, COLOR_MECHANIC, string);
format(string, sizeof(string), "[MECHANIC]: %s has fixed %s's vehicle!", pname, client);
SendClientMessageToAll(COLOR_MECHANIC, string);
new IsMechOnline = 0;
|
Hey nice to see you release things, i'm gonna drop some comments here to help you improve,
1- the variable mechjob[MAX_PLAYERS]; accepts only values 1 and 0 so bool:mechjob[MAX_PLAYERS]; and true/false with if(mechjob[playerid]) || if(!mechjob[playerid]) for 0 and 1 whereas 0 is false and 1 is true would've been better. The same deal applies to the variable 'Repairing' and 'request' 2- For a faster loop instead of doing: Код:
for(new i=0 ; i<MAX_PLAYERS ; i++) Код:
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue; //no need to loop through players not connected
4- You could've destroyed the pickup and cars at OnFilterScriptExit (suggestion and optional) 5- No need at all to reset variables at BOTH onplayerconnect & disconnect, one would be enough 6- Why use this: Код:
new pname[MAX_PLAYER_NAME], string[120];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s is now one of our mechanics in San Andreas!", pname);
7- Instead of this: Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
Код:
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT ) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command"); Код:
if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!"); Код:
if(mechjob[playerid] == 1)
{//code
Код:
else if(GetPlayerState(id) == PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,COLOR_MECHANIC, "That player is not in a vehicle!");
else if(GetPlayerState(id) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "That player is not driving a vehicle!");
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command!");
else if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command!");
10- This: Код:
if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
{
11- Instead of this: Код:
if(vhealth == 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");
if(vhealth > 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");
Код:
if(vhealth >= 1000.0) return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");// >= for bigger than or equal to Код:
GetPlayerName(id, pName, sizeof(pName));
RepairVehicle(GetPlayerVehicleID(id));
format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
Код:
format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
SendClientMessage(playerid, COLOR_MECHANIC, string);
format(string, sizeof(string), "[MECHANIC]: %s has fixed %s's vehicle!", pname, client);
SendClientMessageToAll(COLOR_MECHANIC, string);
Код:
new IsMechOnline = 0; Also the loop right underneath could've been better same as #2 14- At line 263-264 same deal as #8 and #10 The rest is just repeated as the numbers above so take a look at them and try to edit these parts but overall good job +rep. EDIT: I also recommend pastebin/github it would've made it easier to look over the code. |
|
I like the system. You can do more better by RogueDrifter TIPs
|
|
Not bad useful for roleplay servers.
Anyway, Do you have any idea how to tow a bike? I've been trying to make a script for that and so you I think. |
|
Not bad useful for roleplay servers.
Anyway, Do you have any idea how to tow a bike? I've been trying to make a script for that and so you I think. |