SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 05/02/2018, 11:04 PM   #1
MarkNelson
Huge Clucker
 
MarkNelson's Avatar
 
Join Date: Feb 2016
Location: Tunisia
Posts: 465
Reputation: 46
Default Mechanic System V0.1 BETA

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 Y_Less)
- 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
Attached Files
File Type: amx mechsystem.amx (27.4 KB, 5 views)
File Type: pwn mechsystem.pwn (14.5 KB, 22 views)
__________________
Code:
[Filterscript] Mechanic System V0.1 BETA
[Filterscript] Simple PM System
[Filterscript] Mechanic System V0.1 (Improved Version)
Please donate here:
paypal.me/Clark783

Last edited by MarkNelson; 06/02/2018 at 07:38 PM.
MarkNelson is offline   Reply With Quote
Old 05/02/2018, 11:06 PM   #2
willbedie
Gangsta
 
willbedie's Avatar
 
Join Date: Feb 2016
Location: Albania
Posts: 522
Reputation: 40
Default Re: Mechanic System V0.1 BETA(job + mechanics chat + commands)

not bad
__________________


willbedie is online now   Reply With Quote
Old 05/02/2018, 11:36 PM   #3
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,144
Reputation: 345
Default Re: Mechanic System V0.1 BETA

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:
Code:
for(new i=0 ; i<MAX_PLAYERS ; i++)
to avoid the original MAX_PLAYERS number and looping through players not connected you could:
Code:
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:
Code:
                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:
Code:
    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:
Code:
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:
Code:
 if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!");
You didn't have to put this afterwards:
Code:
    if(mechjob[playerid] == 1)
{//code
9- Here :
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!");
Could've been summed up using the way i mentioned on #7
10- This:
Code:
            if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
            {
Same as #8
11- Instead of this:
Code:
                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:
Code:
                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:
Code:
                    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:
Code:
                    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:
Code:
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.
__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 05/02/2018, 11:44 PM   #4
MarkNelson
Huge Clucker
 
MarkNelson's Avatar
 
Join Date: Feb 2016
Location: Tunisia
Posts: 465
Reputation: 46
Default Re: Mechanic System V0.1 BETA

Quote:
Originally Posted by RogueDrifter View Post
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:
Code:
for(new i=0 ; i<MAX_PLAYERS ; i++)
to avoid the original MAX_PLAYERS do and looping through players not connected you could:
Code:
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:
Code:
                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:
Code:
    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:
Code:
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:
Code:
 if(mechjob[playerid] == 0) return SendClientMessage(playerid, COLOR_MECHANIC, "You're not a mechanic!");
You didn't have to put this afterwards:
Code:
    if(mechjob[playerid] == 1)
{//code
9- Here :
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!");
Could've been summed up using the way i mentioned on #7
10- This:
Code:
            if(GetPlayerState(id) == PLAYER_STATE_DRIVER)
            {
Same as #8
11- Instead of this:
Code:
                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:
Code:
                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:
Code:
                    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:
Code:
                    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:
Code:
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
__________________
Code:
[Filterscript] Mechanic System V0.1 BETA
[Filterscript] Simple PM System
[Filterscript] Mechanic System V0.1 (Improved Version)
Please donate here:
paypal.me/Clark783
MarkNelson is offline   Reply With Quote
Old 06/02/2018, 02:28 AM   #5
BulletRaja
Banned
 
Join Date: Dec 2017
Location: India
Posts: 219
Reputation: 20
Default Re: Mechanic System V0.1 BETA

I like the system. You can do more better by RogueDrifter TIPs
BulletRaja is offline   Reply With Quote
Old 06/02/2018, 05:44 AM   #6
MarkNelson
Huge Clucker
 
MarkNelson's Avatar
 
Join Date: Feb 2016
Location: Tunisia
Posts: 465
Reputation: 46
Default Re: Mechanic System V0.1 BETA

Quote:
Originally Posted by BulletRaja View Post
I like the system. You can do more better by RogueDrifter TIPs
Thanks, i'll update it soon to Alpha Version
__________________
Code:
[Filterscript] Mechanic System V0.1 BETA
[Filterscript] Simple PM System
[Filterscript] Mechanic System V0.1 (Improved Version)
Please donate here:
paypal.me/Clark783
MarkNelson is offline   Reply With Quote
Old 06/02/2018, 08:22 AM   #7
ItzColaBoi
Guest
 
Posts: n/a
Default Re: Mechanic System V0.1 BETA

Awesome work bro,i'll use it for my server.+rep
  Reply With Quote
Old 06/02/2018, 10:14 AM   #8
MarkNelson
Huge Clucker
 
MarkNelson's Avatar
 
Join Date: Feb 2016
Location: Tunisia
Posts: 465
Reputation: 46
Default Re: Mechanic System V0.1 BETA

Quote:
Originally Posted by ItzColaBoi View Post
Awesome work bro,i'll use it for my server.+rep
Sure, you can use it at anytime
__________________
Code:
[Filterscript] Mechanic System V0.1 BETA
[Filterscript] Simple PM System
[Filterscript] Mechanic System V0.1 (Improved Version)
Please donate here:
paypal.me/Clark783
MarkNelson is offline   Reply With Quote
Old 06/02/2018, 11:58 AM   #9
TheToretto
Big Clucker
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 71
Reputation: 5
Default Re: Mechanic System V0.1 BETA

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.
TheToretto is offline   Reply With Quote
Old 06/02/2018, 04:49 PM   #10
MarkNelson
Huge Clucker
 
MarkNelson's Avatar
 
Join Date: Feb 2016
Location: Tunisia
Posts: 465
Reputation: 46
Default Re: Mechanic System V0.1 BETA

Quote:
Originally Posted by TheToretto View Post
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
__________________
Code:
[Filterscript] Mechanic System V0.1 BETA
[Filterscript] Simple PM System
[Filterscript] Mechanic System V0.1 (Improved Version)
Please donate here:
paypal.me/Clark783
MarkNelson is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mechanic system error AndreiWow Scripting Help 2 21/12/2015 07:22 AM
[HELP]Leveling the Mechanics of Virtual World System. MAFIAWARS Scripting Help 28 09/10/2013 03:31 PM
[Tool/Web/Other] Chat Box [BETA] Glad2BeHere Tools and Files 0 19/06/2013 06:42 PM
[FilterScript] J_Admin System [BETA][Over 50 commands][MySQL, ZCMD, ..] Jarnu Filterscripts 16 24/11/2012 06:20 PM


All times are GMT. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.