Robbing
#1

Alright, I have a robbing command for my server, you type /robstore and it allows you to rob the blueberry liquor store.
The only problem is that you don't gain cash from it, anyone know why?
pawn Код:
command(robstore, playerid, params[])
{
    if(PlayerToPoint(3, playerid,252.249,-56.554,0.755))
        {
        new sendername[MAX_PLAYER_NAME];
        new string [200];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new robmoney = random(20000);
        SendClientMessage(playerid, 0xFF0000FF, " You have started to rob the Liquer Store. ");
        SendClientMessageToAll(RED, "The Liquer Store in Blueberry is being robbed! ALL Police units respand immediately!");
        SendClientMessage(playerid, YELLOW, "You have been seen on the security cameras! Run away!");
        format(string, sizeof(string), "** You have successfully stolen $%d!",robmoney);
  SendClientMessage(playerid,YELLOW,string);
        GivePlayerMoney(playerid, robmoney);
        }
    return 1;
}
Also how would you make it so that it can only be robbed every 20-30 minutes
Reply
#2

pawn Код:
static bool:steal = false
forward Steal();
// On script top
pawn Код:
command(robstore, playerid, params[])
{
    if(PlayerToPoint(3, playerid,252.249,-56.554,0.755))
        {
        new sendername[MAX_PLAYER_NAME];
        new string [200];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        SendClientMessage(playerid, 0xFF0000FF, " You have started to rob the Liquer Store. ");
        SendClientMessageToAll(RED, "The Liquer Store in Blueberry is being robbed! ALL Police units respand immediately!");
        SendClientMessage(playerid, YELLOW, "You have been seen on the security cameras! Run away!");
        format(string, sizeof(string), "** You have successfully stolen $%d!",random(20000));
  SendClientMessage(playerid,YELLOW,string);
        GivePlayerMoney(playerid, random(20000));
        steal = true;
        SetTimer("Steal",12000000,false); // 20min = 1.200.000
        }
    return 1;
}
pawn Код:
public Steal()
{
    steal = true;
    return 1;
}
Reply
#3

Got some errors/warnings
Код:
C:\Users\Alice\Desktop\Samp Server\gamemodes\VortexRoleplay.pwn(24) : error 001: expected token: ";", but found "forward"
C:\Users\Alice\Desktop\Samp Server\gamemodes\VortexRoleplay.pwn(13710) : warning 206: redundant test: constant expression is non-zero
C:\Users\Alice\Desktop\Samp Server\gamemodes\VortexRoleplay.pwn(13719) : warning 217: loose indentation
C:\Users\Alice\Desktop\Samp Server\gamemodes\VortexRoleplay.pwn(13720) : warning 217: loose indentation
C:\Users\Alice\Desktop\Samp Server\gamemodes\VortexRoleplay.pwn(13721) : warning 204: symbol is assigned a value that is never used: "steal"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
Line 24: forward Steal();
Line 13710: if(PlayerToPoint(3, playerid,252.249,-56.554,0.755))
Line 13721: steal = true;
Line 13720: GivePlayerMoney(playerid, random(20000));
Line 13719: SendClientMessage(playerid,YELLOW,string);
Reply
#4

I am not so good at bool.

But I suggest using "IsPlayerInRangeOfPoint" instead of PlayerToPoint, I heard it is faster.

Indent your code, if you don't know how to, then
You can use this http://dracoblue.net/tidy/pawn/
Reply
#5

On the line before:

pawn Код:
forward Steal();
Add the
Код:
 ;
at before the "forward"

For 13721:
pawn Код:
#pragma unused steal

Код:
warning 206: redundant test: constant expression is non-zero
Never heard about this one. Also, your command:
pawn Код:
command(robstore, playerid, params[])
{
   
    if(PlayerToPoint(3, playerid,252.249,-56.554,0.755))
    {
        if(steal == true)
        {
            return SendClientMessage(playerid, 0xFF0000FF, "You need to wait 20min before steal again");
        }
        else
        new sendername[MAX_PLAYER_NAME];
        new string [200];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        SendClientMessage(playerid, 0xFF0000FF, " You have started to rob the Liquer Store. ");
        SendClientMessageToAll(RED, "The Liquer Store in Blueberry is being robbed! ALL Police units respand immediately!");
        SendClientMessage(playerid, YELLOW, "You have been seen on the security cameras! Run away!");
        format(string, sizeof(string), "** You have successfully stolen $%d!",random(20000));
        SendClientMessage(playerid,YELLOW,string);
        GivePlayerMoney(playerid, random(20000));
        steal = true;
        SetTimer("Steal",12000000,false); // 20min = 1.200.000
    }
    return 1;
}
Reply
#6

I am a co-owner/owner of the server this is for. I made this and I wanted to ask...How can you make a function for the robbery so that the accusal robbery will take around 2 minutes instead of one second?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)