Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: DarkSpread on February 13, 2011, 02:18:27 pm
-
The script is this:
procedure OnPlayerRespawn(ID: Byte);
begin
DoDamage(ID,1);
ForceWeapon(ID,2,7,0);
GiveBonus(ID, 3);
end;
It does DoDamage and GiveBonus but doesn't ForceWeapon
If i do this other, it works:
if GetPlayerStat(ID, 'Alive') then begin
if Text = 'SomeText' then
ForceWeapon(ID,2,7,0);
end;
Someone knows why the script doesn't works?? o.O
-
Forceweapon activates on rewspawn, the problem is that the player gets his weapon that moment, but the weapon he chooses in the weapon tab 'overwrites' that.
-
..and there is a way for "bypass" this? ???
-
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
http://enesce.com/help/index.html?Events/OnWeaponChange.html (http://enesce.com/help/index.html?Events/OnWeaponChange.html)
Description:
This procedure will be called every time a player switches weapons, drops a weapon, picks up a weapon, and when they pick a gun from the respawn menu.
Maybe that will work.
-
Not only doesn't work but it doesn't let me to chat and the server doesn't shutdown D:
(http://i53.tinypic.com/ru61ow.png)
Thanks for the help. Anyone else who has any other ideas?
PS: I WAS USING THIS CODE:
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
OnWeaponChange(ID, 2, 7);
end;
-
Try this:
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
ForceWeapon(ID,2,7,0);
end;
-
Im pretty sure using forceweapon() calls the OnWeaponChange event again, so that would cause an infinite loop, check to see if the weapon he has switched to is correct or not before you do a forceweapon.
-
uhh.. Try checking for the first onweaponchange after respawn. Namely set a flag var to true after a player respawns. Then check if it's true in onweaponchange - you'll know that the player has just picked his weapon. Do whatever magic you need and set the flag var back to false so that you don't end up in an endless loop like you just did... I hope you got what i was trying to say, that should be as close as it gets to what you need.
-
Mmh.. I have an idea: is possible to enable the ForceWeapon on OnWeaponChange only "once time"?
To Stuffy: i tried that script but when i change my weapon the primary always be MP5 and when i drop the weapon see what happens..
(http://i51.tinypic.com/309q2hw.png)
LOL.
-
do what hacktank and dnmr wrote. Create a var or do
if (PrimaryNum <> 2) and (SecondaryNum <> 7) or (PrimaryNum <> 7) and (SecondaryNum <> 2) then ForceWeapon(ID,2,7,0);
Did the "or" because im not sure if the secondary weapon gets the first on change.
-
I solved with this:
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if (PrimaryNum <> 2) and (SecondaryNum <> 7) then ForceWeapon(ID,7,2,0);
end;
But there are other 2 problems..
1. When i change to M79 (secondary), his ammo resets.
2. When i'm using M79 if i drop it.. The same problem.
(http://i56.tinypic.com/t62jba.png)
If there is no possibility to solve these bugs i will leave these how are.
Or at least make something like "If SecondaryWeapon ammo 0 (default ammo) then ForceWeapon Else Nothing" ???
-
Should be easier to do AfterRespawn[ID] := true;in OnPlayerRespawn, and then in OnWeaponChange check if AfterRespawn = true, if yes just change weapons and set AfterRespawn[ID] to false.
Code without checking:
var
AfterRespawn : array[1..32] of boolean;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if AfterRespawn[ID] then begin
ForceWeapon(ID,7,2,0);
AfterRespawn := false;
end;
end;
procedure OnPlayerRespawn(ID: Byte);
begin
AfterRespawn[ID] := true;
end;
-
Type Mismatch :(
-
var
AfterRespawn : array[1..32] of boolean;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: Byte);
begin
if AfterRespawn[ID] then begin
ForceWeapon(ID,7,2,0);
AfterRespawn[ID] := false;
end;
end;
procedure OnPlayerRespawn(ID: Byte);
begin
AfterRespawn[ID] := true;
end;
Check this one.
-
How do you want the weapons to be forced?
I could make a short script if id knew how do you want it to.
-
How do you want the weapons to be forced?
I could make a short script if id knew how do you want it to.
Thanks! :P
For primary weapon MP5 and for secondary M79. :)
EDIT:
To croat1gamer: I solved with Polifen's script: thanks anyway! :) ..And thanks also to Polifen!! ;D
-
Yeah, his will work, personally, id like to add a precaution here and there, but this is also okay.