Author Topic: Forcing weapons  (Read 2031 times)

0 Members and 1 Guest are viewing this topic.

Offline Mexer

  • Soldier
  • **
  • Posts: 121
  • real eyes. realize. real lies.
Forcing weapons
« on: March 02, 2012, 03:38:14 pm »
Hey!

I'm trying to make an Elite vs Predators server  (snipers vs predatored knifers).

The elite (bravo) are only allowed to use barret with any secondary. If they pick something else than barret it will be switched automatically to it. Also, they're not allowed to pick up snipers which will be automatically switched to knives.

The predators are only allowed to use knife and chainsaws; whatever primary they use it will be switched to hands and their only weapon will be knife or chainsaw.

The problem I'm having is that my script for the barret keeps crashing my server in the form of kicking me for flood kick.  Here's a failed code I use for a reference which enters an infinite loop when I switch to my secondary which also turns into a barret. The script is only for the bravos/elites here 'cause that's the one causing me problems:
Code: [Select]
procedure OnJoinTeam(Id, Team: byte);
begin
if Team = 2 then begin
ForceWeapon( Id, 8, GetPlayerStat(Id, 'Secondary'), 0 );
end;
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin

if GetPlayerStat(ID, 'Team') = 2 then begin
if GetPlayerStat(ID, 'Secondary') <> 8
then begin
ForceWeapon( ID, 8, GetPlayerStat(Id, 'Secondary'), 0 );
end;
end;

Soldat devs and community: We want this game to be successful and have new players and make it popular!

Soldat devs and community: But we want the oldskool graphics and bugs and errors to be left alone! Soldat shall never change!!!

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Forcing weapons
« Reply #1 on: March 02, 2012, 04:57:35 pm »
Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if getplayerstat(id,'team') = 2 then if (primarynum <> 8) AND (primarynum < IDFORSOCOM) then forceweapon(ID,8,secondarynum);
end;
I dont remember what the weapon codes are anymore, replace IDFORSOCOM with the socom's id (or whichever secondary's is first, i dont remember x.x).


Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Forcing weapons
« Reply #2 on: March 03, 2012, 05:50:06 pm »
you have a hidden loop here. ForceWeapon() will call OnWeaponChange which calls ForceWeapon which calls.... that's why you were flood kicked, for sending too many weapon packages.
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline Mexer

  • Soldier
  • **
  • Posts: 121
  • real eyes. realize. real lies.
Re: Forcing weapons
« Reply #3 on: March 03, 2012, 08:33:40 pm »
you have a hidden loop here. ForceWeapon() will call OnWeaponChange which calls ForceWeapon which calls.... that's why you were flood kicked, for sending too many weapon packages.

ooh, so forcing the weapon is ALSO a WeaponChange. Foolish me
Soldat devs and community: We want this game to be successful and have new players and make it popular!

Soldat devs and community: But we want the oldskool graphics and bugs and errors to be left alone! Soldat shall never change!!!

Offline machina

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1117
  • The world isn't nice. Why should I be...?
Re: Forcing weapons
« Reply #4 on: March 04, 2012, 09:30:34 am »
Haha! Mad and nice idea... I hope you'll make it happen. It can be interesting :P But I'm worring that snipers can have littlier chances than knifers...

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Forcing weapons
« Reply #5 on: March 06, 2012, 03:51:00 am »