[Tutorial] How to make a simple neon shop for your server.
#1

What you will need for this tutorial:

- The zcmd include by Zeex here.

- Some time.

----------------------------------------------------------------------------------------------------


What to expect in this tutorial?:


- Usage of zcmd.

- Usage of pvars.

- Usage of dialogs.

- Choose from a list of Blue, Red, Green, Yellow or Pink neons.

- Players may remove neons.

- Neons delete when the player destroys the vehicle.

NOTE: You cant really see the neons during the day, but at night they look perfect.

----------------------------------------------------------------------------------------------------

The tutorial:


Ok first you must add the zcmd include(Do not try this step untill you have downloaded zcmd here) so we can use the zcmd proccessor to make our command later in the tutorial.

Under #include <a_samp> add:

pawn Код:
#include <zcmd>
Ok, lets define the neon prices so its easier for you to modify the prices later, im going to make them 10k each. Im also going to make a define for each neon colour just incase you want different colours to have different prices. Were also going to define our dialog id so we can use it later in the tutorial to make it easier for you to change the dialog id if it conflicts with your script/s, and ill define colours so you can change them later also.

Under the includes type(Disregard comments):

pawn Код:
//White Hex(In dialogs)
#define WHITE_HEX {FFFFFF}
//Colour defines(Messages)
#define COLOUR_WHITE 0xFFFFFFAA
#define COLOUR_RED 0xFF0000FF

//Dialog id:
#define NEON_DIALOG 0//You may need to change the id.
//The neon prices:
#define BLUE_NEONS_PRICE 10000//You may want to change this.
#define RED_NEONS_PRICE 10000//You may want to change this.
#define GREEN_NEONS_PRICE 10000//You may want to change this.
#define YELLOW_NEONS_PRICE 10000//You may want to change this.
#define PINK_NEONS_PRICE 10000//You may want to change this.
Ok, now we are going to code our command, may i add you can just use IsPlayerInRangeOfPoint later if you would like a area such as a service station a neon shop.

Now we dont want a shamel or a nrg to be able to add neons so we are doing to use GetVehicleModel to check if there in an appropriate vehicle to add neons to(Note: I have added a few vehicle ids you may like to add/remove some), and if they are show them the neon dialog else there not in an appropriate vehicle to add neons to.

pawn Код:
CMD:neonshop(playerid, params[])//Rename it to w/e you like..
{
    new string[100];//Define our string to use later when we format our neon prices into a string and show it in the dialog..
    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))//Get there vehicle model and switch through each vehicle id to check if there in one of our defined vehicles..
    {
        case 562,565,559,561,560,575,534,567,536,535,576,411,579,602,496,518,527,589,597,419,
        533,526,474,545,517,410,600,436,580,439,549,491,445,604,507,585,587,466,492,546,551,516,
        426,547,405,409,550,566,406,540,421,529,431,438,437,420,525,552,416,433,427,490,528,
        407,544,470,598,596,599,601,428,499,609,524,578,486,573,455,588,403,514,423,
        414,443,515,456,422,482,530,418,572,413,440,543,583,478,554,402,542,603,475,568,504,457,
        483,508,429,541,415,480,434,506,451,555,477,400,404,489,479,442,458,467,558://Switch through these cases and if there in one of these ids..
        {
             format(string, sizeof(string), "WHITE_HEXBlue Neons: $%d\nRed Neons: $%d\nGreen Neons: $%d\nYellow Neons: $%d\nPink Neons: $%d\nRemove Neons: Free", BLUE_NEONS_PRICE, RED_NEONS_PRICE, GREEN_NEONS_PRICE, YELLOW_NEONS_PRICE, PINK_NEONS_PRICE);//Format the string..
             ShowPlayerDialog(playerid, NEON_DIALOG, DIALOG_STYLE_LIST, "WHITE_HEXNeon Shop", string, "Select", "Cancel");//Show the neon dialog with the formatted string..
        }
        default: return SendClientMessage(playerid,COLOUR_RED,"You cannot tune this vehicle.");//Else there not in a any of our defined vehicle ids..
    }
    return true;
}
Ok now we know there in an appropriate vehicle to add neons to when we show them the dialog we can start coding the dialog response/s.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)//Switch through the dialog ids..
    {
        case NEON_DIALOG://For dialog id NEON_DIALOG..
        {
            if(response)//If they click something other than cancel..
            {
                switch(listitem)//Switch the list items..
                {
                    case 0://If they click blue neons..
                    {
                        if(GetPlayerMoney(playerid) >= BLUE_NEONS_PRICE)//Check if there there holding amount is more or equal to BLUE_NEONS_PRICE if so..
                        {
                            SetPVarInt(playerid, "HasBlueNeons", 1);//Set there status in a player variable..
                            SetPVarInt(playerid, "BlueNeons1", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
                            SetPVarInt(playerid, "BlueNeons2", CreateObject(18648,0,0,0,0,0,0));//Set the neon object into a player variable..
                            AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            AttachObjectToVehicle(GetPVarInt(playerid, "BlueNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            GivePlayerMoney(playerid, - BLUE_NEONS_PRICE);//Remove the BLUE_NEONS_PRICE from the players holding amount..
                            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
                            new string[80];//Define our string to use later ti format BLUE_NEONS_PRICE into a string and show it in a message..
                            format(string, sizeof(string), "You have successfully added blue neons to your vehicle. Cost: $%d", BLUE_NEONS_PRICE);//Format the string..
                            SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of BLUE_NEONS_PRICE..
                        }
                    }
                    case 1://If they click red neons..
                    {
                        if(GetPlayerMoney(playerid) >= RED_NEONS_PRICE)//Check if there there holding amount is more or equal to RED_NEONS_PRICE if so..
                        {
                            SetPVarInt(playerid, "HasRedNeons", 1);//Set there status in a player variable..
                            SetPVarInt(playerid, "RedNeons1", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
                            SetPVarInt(playerid, "RedNeons2", CreateObject(18647,0,0,0,0,0,0));//Set the neon object into a player variable..
                            AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            AttachObjectToVehicle(GetPVarInt(playerid, "RedNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            GivePlayerMoney(playerid, - RED_NEONS_PRICE);//Remove the RED_NEONS_PRICE from the players holding amount..
                            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
                            new string[80];//Define our string to use later ti format RED_NEONS_PRICE into a string and show it in a message..
                            format(string, sizeof(string), "You have successfully added red neons to your vehicle. Cost: $%d", RED_NEONS_PRICE);//Format the string..
                            SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of RED_NEONS_PRICE..
                        }
                    }
                    case 2://If they click green neons..
                    {
                        if(GetPlayerMoney(playerid) >= GREEN_NEONS_PRICE)//Check if there there holding amount is more or equal to GREEN_NEONS_PRICE if so..
                        {
                            SetPVarInt(playerid, "HasGreenNeons", 1);//Set there status in a player variable..
                            SetPVarInt(playerid, "GreenNeons1", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
                            SetPVarInt(playerid, "GreenNeons2", CreateObject(18649,0,0,0,0,0,0));//Set the neon object into a player variable..
                            AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            AttachObjectToVehicle(GetPVarInt(playerid, "GreenNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            GivePlayerMoney(playerid, - GREEN_NEONS_PRICE);//Remove the GREEN_NEONS_PRICE from the players holding amount..
                            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
                            new string[80];//Define our string to use later ti format GREEN_NEONS_PRICE into a string and show it in a message..
                            format(string, sizeof(string), "You have successfully added green neons to your vehicle. Cost: $%d", GREEN_NEONS_PRICE);//Format the string..
                            SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of GREEN_NEONS_PRICE..
                        }
                    }
                    case 3://If they click yellow neons..
                    {
                        if(GetPlayerMoney(playerid) >= YELLOW_NEONS_PRICE)//Check if there there holding amount is more or equal to YELLOW_NEONS_PRICE if so..
                        {
                            SetPVarInt(playerid, "HasYellowNeons", 1);//Set there status in a player variable..
                            SetPVarInt(playerid, "YellowNeons1", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
                            SetPVarInt(playerid, "YellowNeons2", CreateObject(18650,0,0,0,0,0,0));//Set the neon object into a player variable..
                            AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            AttachObjectToVehicle(GetPVarInt(playerid, "YellowNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            GivePlayerMoney(playerid, - YELLOW_NEONS_PRICE);//Remove the YELLOW_NEONS_PRICE from the players holding amount..
                            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
                            new string[80];//Define our string to use later ti format YELLOW_NEONS_PRICE into a string and show it in a message..
                            format(string, sizeof(string), "You have successfully added yellow neons to your vehicle. Cost: $%d", YELLOW_NEONS_PRICE);//Format the string..
                            SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of YELLOW_NEONS_PRICE..
                        }
                    }
                    case 4://If they click pink neons..
                    {
                        if(GetPlayerMoney(playerid) >= PINK_NEONS_PRICE)//Check if there there holding amount is more or equal to PINK_NEONS_PRICE if so..
                        {
                            SetPVarInt(playerid, "HasPinkNeons", 1);//Set there status in a player variable..
                            SetPVarInt(playerid, "PinkNeons1", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
                            SetPVarInt(playerid, "PinkNeons2", CreateObject(18651,0,0,0,0,0,0));//Set the neon object into a player variable..
                            AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons1"), GetPlayerVehicleID(playerid), -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            AttachObjectToVehicle(GetPVarInt(playerid, "PinkNeons2"), GetPlayerVehicleID(playerid), 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);//Attatch the neon object to the vehicle(Do not change coordinates)..
                            GivePlayerMoney(playerid, - PINK_NEONS_PRICE);//Remove the PINK_NEONS_PRICE from the players holding amount..
                            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);//Play the sound that you hear when you tune a car in transfender..
                            new string[80];//Define our string to use later ti format PINK_NEONS_PRICE into a string and show it in a message..
                            format(string, sizeof(string), "You have successfully added pink neons to your vehicle. Cost: $%d", PINK_NEONS_PRICE);//Format the string..
                            SendClientMessage(playerid, COLOUR_WHITE, string);//Send a client message with the formatted string..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_RED,"You dont have enough money to purchase this modification.");//Else they dont have the cost of PINK_NEONS_PRICE..
                        }
                    }
                    case 5://If they click remove neons..
                    {
                        if(GetPVarInt(playerid, "HasBlueNeons") == 1)//If they have blue neons..
                        {
                            DeletePVar(playerid, "HasBlueNeons");//Remove there status..
                            DestroyObject(GetPVarInt(playerid, "BlueNeons1"));//And objects..
                            DestroyObject(GetPVarInt(playerid, "BlueNeons2"));//And objects..
                            SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
                        }
                        else if(GetPVarInt(playerid, "HasRedNeons") == 1)//If they have red neons..
                        {
                            DeletePVar(playerid, "HasRedNeons");//Remove there status..
                            DestroyObject(GetPVarInt(playerid, "RedNeons1"));//And objects..
                            DestroyObject(GetPVarInt(playerid, "RedNeons2"));//And objects..
                            SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
                        }
                        else if(GetPVarInt(playerid, "HasGreenNeons") == 1)//If they have green neons..
                        {
                            DeletePVar(playerid, "HasGreenNeons");//Remove there status..
                            DestroyObject(GetPVarInt(playerid, "GreenNeons1"));//And objects..
                            DestroyObject(GetPVarInt(playerid, "GreenNeons2"));//And objects..
                            SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
                        }
                        else if(GetPVarInt(playerid, "HasYellowNeons") == 1)//If they have yellow neons..
                        {
                            DeletePVar(playerid, "HasYellowNeons");//Remove there status..
                            DestroyObject(GetPVarInt(playerid, "YellowNeons1"));//And objects..
                            DestroyObject(GetPVarInt(playerid, "YellowNeons2"));//And objects..
                            SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
                        }
                        else if(GetPVarInt(playerid, "HasPinkNeons") == 1)//If they have pink neons..
                        {
                            DeletePVar(playerid, "HasPinkNeons");//Remove there status..
                            DestroyObject(GetPVarInt(playerid, "PinkNeons1"));//And objects..
                            DestroyObject(GetPVarInt(playerid, "PinkNeons2"));//And objects..
                            SendClientMessage(playerid, COLOUR_WHITE, "You have successfully removed the neons from your vehicle.");//Send them a message telling them they removed there neons..
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOUR_WHITE, "You dont have any neons to remove.");//Else they dont have any neons to remove..
                        }
                    }
                }
            }
        }
    }
    return 1;
}
Ok, now we can select/purchase/remove neons we need to remove the neons if they destroy there vehicle to prevent the neons reappearing on respawned vehicles.

Finally were going to loop through MAX_PLAYERS and check if there vehicle id is the vehicle id that was destroyed and if so remove the neons.

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
    new i;//New i which defines our playerid..
    for(i = 0; i < MAX_PLAYERS; i ++)// i = 0 and is less than MAX_PLAYERS, increase 0 and loop untill you get to MAX_PLAYERS and return 1..
    {
        if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid)//If the player id is connected and there vehicle id = the vehicleid that was destroyed..
        {
            if(GetPVarInt(i, "HasBlueNeons") == 1)//If they have blue neons..
            {
                DeletePVar(i, "HasBlueNeons");//Remove there status..
                DestroyObject(GetPVarInt(i, "BlueNeons1"));//And objects..
                DestroyObject(GetPVarInt(i, "BlueNeons2"));//And objects..
            }
            else if(GetPVarInt(i, "HasRedNeons") == 1)//If they have red neons..
            {
                DeletePVar(i, "HasRedNeons");//Remove there status..
                DestroyObject(GetPVarInt(i, "RedNeons1"));//And objects..
                DestroyObject(GetPVarInt(i, "RedNeons2"));//And objects..
            }
            else if(GetPVarInt(i, "HasGreenNeons") == 1)//If they have green neons..
            {
                DeletePVar(i, "HasGreenNeons");//Remove there status..
                DestroyObject(GetPVarInt(i, "GreenNeons1"));//And objects..
                DestroyObject(GetPVarInt(i, "GreenNeons2"));//And objects..
            }
            else if(GetPVarInt(i, "HasYellowNeons") == 1)//If they have yellow neons..
            {
                DeletePVar(i, "HasYellowNeons");//Remove there status..
                DestroyObject(GetPVarInt(i, "YellowNeons1"));//And objects..
                DestroyObject(GetPVarInt(i, "YellowNeons2"));//And objects..
            }
            else if(GetPVarInt(i, "HasPinkNeons") == 1)//If they have pink neons..
            {
                DeletePVar(i, "HasPinkNeons");//Remove there status..
                DestroyObject(GetPVarInt(i, "PinkNeons1"));//And objects..
                DestroyObject(GetPVarInt(i, "PinkNeons2"));//And objects..
            }
        }
    }
    return 1;
}
----------------------------------------------------------------------------------------------------

Credits:

- <a_samp> - Credits to the samp dev team for there callbacks/functions.
- <zcmd> - Credits to Zeex for his/her command proccessor.

----------------------------------------------------------------------------------------------------

Feel free to post any comments or questions if you need any help.

Here is an example filterscript for those who like to just look at the code to see how it is done and/or test it.

Mirrors welcome.

----------------------------------------------------------------------------------------------------

Godhimself



Reply
#2

I won't appreciate any of your works, look at your name.

God is God. You can't name yourself Godhimself. Oh pathetic.
Reply
#3

Quote:
Originally Posted by Ehab1911
Посмотреть сообщение
I won't appreciate any of your works, look at your name.

God is God. You can't name yourself Godhimself. Oh pathetic.
Lol grow up there is no such thing as "God", Its the 21st Centery Buddy. xD

Quote:

No Evidence Of Existance, Is Evidence Of Non Existance

Reply
#4

Quote:
Originally Posted by Godhimself
Посмотреть сообщение
Lol grow up there is no such thing as "God", Its the 21st Centery Buddy. xD
How you know god doesn't exist? Jesus came and told you?

Good tut.
Reply
#5

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
How you know god doesn't exist? Jesus came and told you?

Good tut.
OFF TOPIC: Ok, Scientists have already tried to find the "Higgs Bosun" particle (God Particle) and failed after 2 years of searching.

Now this FACT makes this saying a FACT...

Quote:

No Evidence Of Existance, Is Evidence Of Non Existance

Atheistism has risen in the 21st centery, Why is this?, Maybe becuase it just dont make sense anymore, And there is NO evidence to support religion, But endless evidence to support science. Study the big bang, Electrons, Protons & Neutrons along with the evolution of the domestic pig then come back with your religious thoughts.

Please dont take this to offence people, I respect peoples beliefs just as much as you should respect mine.

ON TOPIC: Thanks

@Horrible

Sorry im not going to help you steal my work.

pawn Код:
print("\n--------------------------------------");
print(" Neon Filterscript by Horribles");
print("--------------------------------------\n")
I didnt see any credits for myself, Just my codes/comments and a modified command name with the original credits removed.
Reply
#6

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
How you know god doesn't exist? Jesus came and told you?
I'm fairly certain that if he rejects the existence of god, he probably doesn't think "Jesus" told him such a thing, either.

Just sayin'.
Reply
#7

Quote:
Originally Posted by ev0lutionnn
Посмотреть сообщение
I'm fairly certain that if he rejects the existence of god, he probably doesn't think "Jesus" told him such a thing, either.

Just sayin'.
Well said.

Now may we finnally evolve some brain cells and bypass this subject to focus on the feedback sides of things with my tutorial?, in which i put some time into.
Reply
#8

Quote:
Originally Posted by Godhimself
Посмотреть сообщение
OFF TOPIC: Ok, Scientists have already tried to find the "Higgs Bosun" particle (God Particle) and failed after 2 years of searching.

Now this FACT makes this saying a FACT...



Atheistism has risen in the 21st centery, Why is this?, Maybe becuase it just dont make sense anymore, And there is NO evidence to support religion, But endless evidence to support science. Study the big bang, Electrons, Protons & Neutrons along with the evolution of the domestic pig then come back with your religious thoughts.

Please dont take this to offence people, I respect peoples beliefs just as much as you should respect mine.

ON TOPIC: Thanks

@Horrible

Sorry im not going to help you steal my work.

pawn Код:
print("\n--------------------------------------");
print(" Neon Filterscript by Horribles");
print("--------------------------------------\n")
I didnt see any credits for myself, Just my codes/comments and a modified command name with the original credits removed.
sry i forgot to add your name now ur name is added please help......
Reply
#9

Quote:
Originally Posted by Ehab1911
Посмотреть сообщение
I won't appreciate any of your works, look at your name.

God is God. You can't name yourself Godhimself. Oh pathetic.
And how is the name actually connected to this tutorial?

OT: It's a good tutorial, well explained.
Reply
#10

nice tutorial. Neon is useful.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)