[Tutorial] How to make a simple Search system
#1

This is my first tutorial, I hope you like it :)

What you'll need:

ZCMD - Link

First, be sure to include zcmd on top of the script

pawn Code:
#include <a_samp>
#include <zcmd>
Next thing is to forward and create the SearchSystem function

pawn Code:
forward SearchSystem();
public SearchSystem()
{
    new string[128], moneyamount = 1000 + random(1000);  //This is setting up the variables that will show the amount of money you find.
    GivePlayerMoney(playerid, moneyamount); //This is giving the player the random amount of money that was generated.
    format(string, sizeof(string), "You have found $%i.", moneyamount);  //This is formatting the string to be used in the SendClientMessage.
    SendClientMessage(playerid, 0xFFFFFFF, string);  //This will display the message to the player.
    return 1;
}
Next thing is to create the search command (with zcmd, you don't need to use OnPlayerCommandText, but you can just place this anywhere in the script. I'd post it under OnPlayerCommandText for organizing reasons)

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

CMD:search(playerid, params[]) //This is stating what the command will be named between the "CMD:" and "(", in this case, it's 'search'.
{
    SetTimerEx("SearchSystem", 5000, false, "i", playerid);  //This is the timer that will go off for the player when he types the command in.
    GameTextForPlayer(playerid, "Searching...", 4500, 3); //A message that will appear on the screen, showing that it's working.
    return 1;
}
I know it's a simply tutorial, but it can help give you ideas on where to apply this in other cases. I hope this helped you guys, especially for those who are new to pawn :)
Reply


Messages In This Thread
How to make a simple Search system - by DTV - 16.09.2014, 22:08
Re: How to make a simple Search system - by Mrashad - 17.09.2014, 11:16
Re: How to make a simple Search system - by Rudy_ - 17.09.2014, 12:27
Re: How to make a simple Search system - by Stinged - 17.09.2014, 12:31
Re: How to make a simple Search system - by TheRaGeLord - 16.01.2015, 10:29
Re: How to make a simple Search system - by ikkentim - 16.01.2015, 10:37
Re: How to make a simple Search system - by Schneider - 16.01.2015, 12:34
Re: How to make a simple Search system - by Rufio - 18.01.2015, 11:02

Forum Jump:


Users browsing this thread: 1 Guest(s)