[Tutorial] How to create a simple car repair shop
#1

Simple Car Repair Shop Tutorial


Hello everyone! I started scripting yesterday and (even though it's a pretty simple) I was surprised that I was able to create this script on my own, so I wanted to share it with you!

It's a basic script that allows you to repair you vehicle using a command in a certain place.

First Step (1st.)

The easiest way is just to open a new file in pawno with all the callbacks there.

Well anyways.. You need only this one included. Place it in the very top of the script (if you didn't open a new file).
pawn Code:
#include <a_samp>
Second Step (2st.)

We will create a pickup icon so we can see where our repairing shop is, so go to public OnGameModeInit:

pawn Code:
public OnGameModeInit()
{
    CreatePickup(1239, 1 , X , Y , Z , -1);
             return 1;
}
Now you have created a pickup icon.

Third Step (3st.)

Allright the last thing we want to do is write the command and it's done! Go to public OnPlayerCommandText

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{

        if (!strcmp(cmdtext , "/vrepair" , true))// The command itself. You can replace it with whatever command you like.
    {
            if(IsPlayerInAnyVehicle(playerid))// Check if the player is inside a vehicle.
            {
                if(IsPlayerInRangeOfPoint(playerid,  2.0 , X, -Y, Z))//Check if the player is on the area where the command can be executed.
                    {
                               if(GetPlayerMoney(playerid) < 750) return SendClientMessage(playerid , 0xFFFFFFFF, "You don't have enough money");
                        {
                        new vehicleid = GetPlayerVehicleID(playerid);// Gets the player's vehicle id.
                        SetVehicleHealth(vehicleid , 1000.0);//Sets the player's vehicle's health to full.
                        GivePlayerMoney(playerid , -750);//Takes an amount of money(in this case 750)from the player.
                        SendClientMessage(playerid , 0xFFFFFFFF , "You have repaired your vehicle for $750");//Simple message for the player.
                        return 1;
                    }
            }
 }
                                 return 0;
}
That's about it! You can create a map icon marker for it also and add some more messages and stuff to it, but this would be the basic structure. If you spot any mistakes in it, feel free to correct me.
Reply
#2



DUDE! NICE EXPLAINING ++++REP OMG
Reply
#3

Quote:
Originally Posted by Sellize
View Post


DUDE! NICE EXPLAINING ++++REP OMG
What's so about it?`

I didn't say that it's the most advanced script ever created or anything near it.
I think you get the basic idea of it.
Reply
#4

Not bad
Reply
#5

Quote:
Originally Posted by Sellize
View Post


DUDE! NICE EXPLAINING ++++REP OMG
You're so retarded, he just said that he started scripting yesterday and this is just perfect if he started(begun) to script yesterday, good job mate!
Reply
#6

Quote:
Originally Posted by Birdkid1999
View Post
Not bad
Quote:
Originally Posted by DaniceMcHarley
View Post
You're so retarded, he just said that he started scripting yesterday and this is just perfect if he started(begun) to script yesterday, good job mate!
Thanks for the feedback!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)