Weapon on Robbery - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Weapon on Robbery (
/showthread.php?tid=577975)
Weapon on Robbery -
PowerF - 15.06.2015
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;
}
Re: Weapon on Robbery -
amirab - 15.06.2015
PHP код:
COMMAND:robstore(playerid, params[])
{
if(playerData[playerid][playerAlreadyLogin])
{
if(GetPlayerWeapon(playerid) == weapon id )
{
startRobbery(playerid);
}
}
return 1;
}
Re: Weapon on Robbery -
PowerF - 15.06.2015
okay thanks,btw,how do i add weapons more than 1?
like
Код:
if(GetPlayerWeapon(playerid) == 4,24 )
is that right?
Re : Weapon on Robbery -
Dutheil - 15.06.2015
Here I use switch+case, because this is more optimized.
PHP код:
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);
return 1;
}
Re: Weapon on Robbery -
PowerF - 15.06.2015
Код:
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
Re : Weapon on Robbery -
Dutheil - 15.06.2015
Ah shit, I don't think the braces are compulsory. Add a "return 1;" at the end of your function startRobbery
PHP код:
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);
}
return 1;
}
Re: Weapon on Robbery -
PowerF - 16.06.2015
btw,how do i return to SendClientMessage the players doesn't have that weapons?
Re: Weapon on Robbery -
bgedition - 16.06.2015
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;
}
Re : Weapon on Robbery -
Dutheil - 16.06.2015
Or that...
PHP код:
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);
}
return SendClientMessage(playerid, -1, "You sould use Bat, Deagle, Knife, Katana or Chainsaw to do the robbery.");
}