[Tutorial] How to make a /robshop cmd
#8

Quote:
Originally Posted by DarkLored
View Post
Hello todays tutorial is about how to make a robbery command in shops

so step one
we include streamer sscanf2 zcmd and ofcourse a_samp
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <streamer>
Second Step
We define the color
pawn Code:
#define COLOR_LIGHTBLUE 0x00E1FF
Third Step
we add the checkpoint variable so we can actually make a checkpoint put it on the top of your script
pawn Code:
new Checkpoint[20];
Fourth Step
we create the checkpoints inside OnGameModeInt here i will show you
pawn Code:
public OnGameModeInIt()
{
   Checkpoint[3] = CreateDynamicCP(1481.0745,-1772.3140,18.7958,2,-1,-1,-1,30);//City Hall Enter
   Checkpoint[4] = CreateDynamicCP(390.7699,173.8530,1008.3828,2,-1,3,-1,100);//City Hall Exit
   Checkpoint[5] = CreateDynamicCP(361.9961,173.6242,1008.3828,3,-1,3,-1,100);//City Hall Robbery Place
   return 1;
}
Five Step
we forward this put it on the top of the script as well but under the includes
pawn Code:
forward CityHallRobAgain(playerid);
Six Step
we create a public function called OnPlayerEnterDynamicCP
pawn Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
        if(checkpointid == Checkpoint[3])
    {
       SendClientMessage(playerid, COLOR_LIGHTBLUE, "Welcome to Los Santos City Hall");
       SetPlayerInterior(playerid,3);
       SetPlayerPos(playerid,387.5708,173.8486,1008.3828);
       SetPlayerFacingAngle(playerid,89.2370);
    }
    if(checkpointid == Checkpoint[4])
    {
       SetPlayerInterior(playerid,0);
       SetPlayerPos(playerid,1481.4359,-1768.5748,18.7958);
       SetPlayerFacingAngle(playerid,2.7449);
    }
    if(checkpointid == Checkpoint[5])
    {
       SendClientMessage(playerid,COLOR_LIGHTBLUE,"Type /robshop to start a robbbery!");
    }
    return 1;
}
Seven Step
we create the command itself like this
pawn Code:
CMD:robshop(playerid,params[])
{
    if(IsPlayerInDynamicCP(playerid,Checkpoint[5]))
    {
       SetPVarInt(playerid, "RobbingCityHall", 30);
       SetPVarInt(playerid, "CityHallRobbedRecently", 1);
       IncreaseWantedLevel(playerid,4);
       @Robbing1(playerid);
       return 1;
    }
    return 1;
}
Eight Step
As you can see there is a robbing1 there this is the timer when your robbing the shop
pawn Code:
@Robbing1(playerid);
@Robbing1(playerid)
{
    new mrand =random(GetPlayerMoney(playerid));
    new string[120];
    new Time = GetPVarInt(playerid, "RobbingCityHall");
    if(!IsPlayerConnected(playerid))
        return 0;

    if(Time < 1)
    {
      SetPVarInt(playerid, "RobbingCityHall", 0);
      SetTimer("CityHallRobAgain", 360000, 0);
      GivePlayerMoney(playerid,mrand);
      IncreaseScore(playerid,1);
      format(string,sizeof(string),"You have succesfully robbed $%d",mrand,playerid);
      return SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    }

    new str[30];
    format(str, sizeof(str), "Robbery time left: %d", Time);
    GameTextForPlayer(playerid, str, 2500, 3); // Change it if you want

    SetPVarInt(playerid, "RobbingCityHall", Time - 1); // Decrease the player's jail time
    SetTimerEx("@Robbing1", 1000, false, "i", playerid);
    return 1;
}
Last step
we need to add this public function
pawn Code:
public CityHallRobAgain(playerid)
{
   if(GetPVarInt(playerid, "CityHallRobbedRecently") == 1)
   {
       SetPVarInt(playerid, "CityHallRobbedRecently", 0);
       return 1;
   }
   return 1;
}
Hope it helped you
hi!
I want add command robbery one cabinet money use command bump receive the new money help
Reply


Messages In This Thread
How to make a /robshop cmd - by DarkLored - 15.10.2013, 23:19
Re: How to make a /robshop cmd - by Sublime - 16.10.2013, 02:11
Re: How to make a /robshop cmd - by DarkLored - 16.10.2013, 02:26
Re: How to make a /robshop cmd - by iZN - 16.10.2013, 03:47
Re: How to make a /robshop cmd - by DarkLored - 16.10.2013, 19:06
Re: How to make a /robshop cmd - by TahaAsif12 - 19.11.2013, 15:02
Re: How to make a /robshop cmd - by DarkLored - 19.11.2013, 18:37
Re: How to make a /robshop cmd - by rynhok2 - 21.12.2013, 18:42
Re: How to make a /robshop cmd - by Hansrutger - 21.12.2013, 18:46
Re: How to make a /robshop cmd - by rynhok2 - 22.12.2013, 08:18

Forum Jump:


Users browsing this thread: 1 Guest(s)