[FilterScript] Mechanic System V0.1 BETA
#1

MarkNelson's Mechanic System V0.1 Beta
Well, i was bored today and i made this mechanic system. In addition to that, this mechanic system has commands and features too.
pictures:






System Commands:
- /tow to tow the vehicle
- /mc [message] to use the mechanics chat
- /mechanic [message] to request a mechanic service
- /mreply [message] to respond to your client's request
- /mechanics to view the list of the available mechanics around the city
- /ljob to leave the mechanic job
- /fix [Player ID] to repair the player's car
- /mechanichelp to view the mechanic cmds list

How it works:
Well, to fix client's cars, you have to be near the client, and that client must be in a vehicle after that type /fix [Player ID] and his car will be fixed. In addition to that, you'll get +$4200 for fixing the client's vehicle and client won't lose money, this system is good for RPG i think or freeroam server. Also, if you die you lose your job and you have to go again to the mechanics center and take that job again.
If you request for mechanic services you will be able to request again after 1 minute to evade the spam
And after requesting for it, mechanics will see your request in their chat and use /mreply [ID] [message] and respound you then the player will get a message like "repound from %s [id] : blablabla"
And the other mechanics will get a notification like "%s has responded to %s. Answer : blablabla"



Includes needed:
- Sscanf2 (Thanks to ******)
- Streamer (Thanks to Incognito)
- Zcmd (Thanks to ZeeX)
- a_samp.inc of course (Thanks to samp team for making samp)

Bugs:
There are no bugs in this system and i fixed all of them.
PS: if you find any bug PM me through the forums or leave a reply here, thank you!
There is vehicle restriction which makes the mechanics to drive the tow trucks only.
Note:
Sorry guys but i didn't find someone to test /fix and some commands with him. feel free to use it
Pastebin:
https://pastebin.com/QQ6F7z5S
Reply
#2

not bad
Reply
#3

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++)
to avoid the original MAX_PLAYERS number and looping through players not connected you could:
Код:
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
    if(!IsPlayerConnected(i)) continue; //no need to loop through players not connected
3- There's absolutely no need for Getname and GetPlayerNameEx only one of them would work perfectly for all situations.
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);
When you already made a function to get the player's name? it would've been better to put it to use
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");
You could've done this:
Код:
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT ) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
8- And if you already used this:
Код:
 if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!");
You didn't have to put this afterwards:
Код:
    if(mechjob[playerid] == 1)
{//code
9- Here :
Код:
        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!");
Could've been summed up using the way i mentioned on #7
10- This:
Код:
            if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
            {
Same as #8
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!");
You could've done this:
Код:
                if(vhealth >= 1000.0)  return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");// >= for bigger than or equal to
12- Here:
Код:
                    GetPlayerName(id, pName, sizeof(pName));
                    RepairVehicle(GetPlayerVehicleID(id));
                    format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
Same as #6 repeated 2x times at the same spot also using string then formatting it and then defining another string called 'stringx' would've been better to re-format the older string after using sendclientmessage like this:
Код:
                    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);
13- This:
Код:
new IsMechOnline = 0;
Is not needed to be equaled to 0 on definition as the variable is already 0 the moment you define it,
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.
Reply
#4

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
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++)
to avoid the original MAX_PLAYERS do and looping through players not connected you could:
Код:
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
    if(!IsPlayerConnected(i)) continue; //no need to loop through players not connected
3- There's absolutely no need for Getname and GetPlayerNameEx only one of them would work perfectly for all situations.
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);
When you already made a function to get the player's name? it would've been better to put it to use
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");
You could've done this:
Код:
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT ) return SendClientMessage(playerid, COLOR_MECHANIC, "You have to be on foot to use this command");
8- And if you already used this:
Код:
 if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!");
You didn't have to put this afterwards:
Код:
    if(mechjob[playerid] == 1)
{//code
9- Here :
Код:
        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!");
Could've been summed up using the way i mentioned on #7
10- This:
Код:
            if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
            {
Same as #8
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!");
You could've done this:
Код:
                if(vhealth >= 1000.0)  return SendClientMessage(playerid, COLOR_MECHANIC, "That player's vehicle has enough health already!");// >= for bigger than or equal to
12- Here:
Код:
                    GetPlayerName(id, pName, sizeof(pName));
                    RepairVehicle(GetPlayerVehicleID(id));
                    format(string, sizeof(string), "You've successfully repaired %s's vehicle (ID: %d)! +$4200", pName, id);
Same as #6 repeated 2x times at the same spot also using string then formatting it and then defining another string called 'stringx' would've been better to re-format the older string after using sendclientmessage like this:
Код:
                    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);
13- This:
Код:
new IsMechOnline = 0;
Is not needed to be equaled to 0 on definition as the variable is already 0 the moment you define it,
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.
Well, i knew that there are some useless/repeated lines and some of them need optimizations but i was lazy and released the filterscript and called it Mechanic System V0.1 BETA.
Thanks btw. I'll update it soon and try to follow your tips
Reply
#5

I like the system. You can do more better by RogueDrifter TIPs
Reply
#6

Quote:
Originally Posted by BulletRaja
Посмотреть сообщение
I like the system. You can do more better by RogueDrifter TIPs
Thanks, i'll update it soon to Alpha Version
Reply
#7

Awesome work bro,i'll use it for my server.+rep
Reply
#8

Quote:
Originally Posted by ItzColaBoi
Посмотреть сообщение
Awesome work bro,i'll use it for my server.+rep
Sure, you can use it at anytime
Reply
#9

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.
Reply
#10

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
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.
I don't think so, because it's impossible to tow a bike in GTA SA.
i didn't try that
Reply
#11

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
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.
You can try attaching an object to some vehicle to make towing look real then spam SetVehiclePos(bikeid, x of towing car, y of towing car, z of towing car);
and then edit x+2 or y+2 depending on the position you want of the bike it'll look ugly but possible.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)