Weapon on Robbery
#1

how do i allow Weapon such as Bat,Deagle,Knife,katana,Chainsaw to allow the robbery
and if player doesn't have the weapons,it will cancel the robbery

Код:
COMMAND:robstore(playerid, params[])
{
	if(playerData[playerid][playerAlreadyLogin])
	{
		startRobbery(playerid);
	}
	return 1;
}
Reply
#2

PHP код:
COMMAND:robstore(playeridparams[])
{
    if(
playerData[playerid][playerAlreadyLogin])
    {
            if(
GetPlayerWeapon(playerid) == weapon id )
            {
        
startRobbery(playerid);
             }
    }
    return 
1;

Reply
#3

okay thanks,btw,how do i add weapons more than 1?

like
Код:
if(GetPlayerWeapon(playerid) == 4,24 )
is that right?
Reply
#4

Here I use switch+case, because this is more optimized.

PHP код:
COMMAND:robstore(playeridparams[])
{
    if(!
playerData[playerid][playerAlreadyLogin]) return 1;
    switch(
GetPlayerWeapon(playerid))
        case 
WEAPON_BATWEAPON_DEAGLEWEAPON_KNIFEWEAPON_KATANAWEAPON_CHAINSAW: return startRobbery(playerid);    
    return 
1;

Reply
#5

Код:
F:\project\pawno\include\commands.inc(2029) : error 001: expected token: "{", but found "case"
F:\project\pawno\include\commands.inc(2029) : warning 209: function "beginRobbery" should return a value
F:\project\pawno\include\commands.inc(2031) : error 002: only a single statement (or expression) can follow each "case"
F:\project\pawno\include\commands.inc(2031) : warning 215: expression has no effect
F:\project\pawno\include\commands.inc(2032) : warning 209: function "cmd_robstore" should return a value
Reply
#6

Ah shit, I don't think the braces are compulsory. Add a "return 1;" at the end of your function startRobbery

PHP код:
COMMAND:robstore(playeridparams[])
{
    if(!
playerData[playerid][playerAlreadyLogin]) return 1;
    switch(
GetPlayerWeapon(playerid))
    {
        case 
WEAPON_BATWEAPON_DEAGLEWEAPON_KNIFEWEAPON_KATANAWEAPON_CHAINSAW: return startRobbery(playerid);
    }    
    return 
1;

Reply
#7

btw,how do i return to SendClientMessage the players doesn't have that weapons?
Reply
#8

Try this:
Код:
COMMAND:robstore(playerid, params[]) 
{ 
    if(!playerData[playerid][playerAlreadyLogin]) return 1; 
    switch(GetPlayerWeapon(playerid)) 
    { 
        case WEAPON_BAT, WEAPON_DEAGLE, WEAPON_KNIFE, WEAPON_KATANA, WEAPON_CHAINSAW: return startRobbery(playerid);
        default: return SendClientMessage(playerid, -1, "You sould use Bat, Deagle, Knife, Katana or Chainsaw to do the robbery.");
    }     
    return 1; 
}
Reply
#9

Or that...

PHP код:
COMMAND:robstore(playeridparams[]) 

    if(!
playerData[playerid][playerAlreadyLogin]) return 1
    
    switch(
GetPlayerWeapon(playerid)) 
    { 
        case 
WEAPON_BATWEAPON_DEAGLEWEAPON_KNIFEWEAPON_KATANAWEAPON_CHAINSAW: return startRobbery(playerid); 
    }     
    
    return 
SendClientMessage(playerid, -1"You sould use Bat, Deagle, Knife, Katana or Chainsaw to do the robbery.");

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)