SA-MP Forums Archive
[Tutorial] How to create a simple car repair shop - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create a simple car repair shop (/showthread.php?tid=457688)



How to create a simple car repair shop - Heisenbergx2 - 12.08.2013

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.


Re: How to create a simple car repair shop - Sellize - 12.08.2013



DUDE! NICE EXPLAINING ++++REP OMG


Re: How to create a simple car repair shop - Heisenbergx2 - 12.08.2013

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.


Re: How to create a simple car repair shop - Birdkid1999 - 16.08.2013

Not bad


Re: How to create a simple car repair shop - Beckett - 16.08.2013

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!


Re: How to create a simple car repair shop - Heisenbergx2 - 16.08.2013

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!