Author Topic: I need some help (no im not a noob)  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

Offline Tosty

  • Soldier
  • **
  • Posts: 172
  • Ultimate TW Medic
    • Just Click it
I need some help (no im not a noob)
« on: August 18, 2007, 04:32:59 pm »
Ok i got a script that will spaw a knife when u change wep,pickone from start menu,  or drop or pickone up


Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),12);
end;

I need it to just spaw a knife when you drop it



Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: I need some help (no im not a noob)
« Reply #1 on: August 18, 2007, 04:43:18 pm »
When you drop... the knife?

There's the quick and dirty solution that'll spawn a knife at the player any time he throws a weapon out (not only knives):

Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if PrimaryNum=255 then
     SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),12);
end;

Another way would be to temporarily store the current Primary and Secondary weapon of the player in an array and then check if the player had a knife equipped when he loses his current weapon.

Something along the lines of this:

Code: [Select]
var
player_primary,player_secondary: array[1..32] of byte;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if (PrimaryNum=255) and (player_primary[ID]=12) then
     SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),12);
player_primary[ID]:=PrimaryNum;
player_secondary[ID]:=SecondaryNum;
end;

And another piece of advice. Since you spawn the knife at the player's current position I assume you want him to pick that knife up immediately when he loses it (=infinite knives?). Instead of spawning the knife object you could just use ForceWeapon:

Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if PrimaryNum=255 then
     ForceWeapon(ID,12,12,0);
end;

That piece of code would equip the player with two knives whenever he'd throw out a weapon. Don't know if that's what you asked for, but meh.

Offline Tosty

  • Soldier
  • **
  • Posts: 172
  • Ultimate TW Medic
    • Just Click it
Re: I need some help (no im not a noob)
« Reply #2 on: August 18, 2007, 06:17:10 pm »
Ok thanks

I may not be a noob but i still only know the basics of scripting

(Ex.Spawitem, createbullet, and so on.....)



Offline Ttil_Np.csWoW

  • Major
  • *
  • Posts: 55
  • The Berserkers Are Coming....
Re: I need some help (no im not a noob)
« Reply #3 on: August 18, 2007, 07:16:46 pm »
Code: [Select]
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if PrimaryNum=255 then
     ForceWeapon(ID,12,12,0);
end;
But wont the player just get baned for a not allowed weppion?
I will be back to play soldat, just not now , but i will....... some day.

Offline Tosty

  • Soldier
  • **
  • Posts: 172
  • Ultimate TW Medic
    • Just Click it
Re: I need some help (no im not a noob)
« Reply #4 on: August 18, 2007, 07:21:44 pm »
Ok i jst tryed it out and it gave me the rambo bow (not the knife)

And yes it dose ban you



Offline Xxypher

  • Veteran
  • *****
  • Posts: 1319
  • Soldat Veteran.
Re: I need some help (no im not a noob)
« Reply #5 on: August 18, 2007, 07:22:45 pm »
He forced the wrong weapon, change the weapon ID.

Offline Tosty

  • Soldier
  • **
  • Posts: 172
  • Ultimate TW Medic
    • Just Click it
Re: I need some help (no im not a noob)
« Reply #6 on: August 18, 2007, 07:26:07 pm »
I allredy did



Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: I need some help (no im not a noob)
« Reply #7 on: August 19, 2007, 01:25:32 am »
Ok i jst tryed it out and it gave me the rambo bow (not the knife)

And yes it dose ban you

Right, my bad. Just change the force weapon ID from 12 into 14.