16.09.2014, 22:08
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
Next thing is to forward and create the SearchSystem function
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)
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 :)
What you'll need:
ZCMD - Link
First, be sure to include zcmd on top of the script
pawn Code:
#include <a_samp>
#include <zcmd>
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;
}
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;
}