Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: koolazngy94 on June 19, 2009, 08:44:43 pm
-
I'm new to making script and I finish reading the tutorial. I made a test script but it didn't work.
procedure SetWeaponActive(ID, WeaponNum: byte; State: boolean);
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;
SetWeaponActive won't work or WeaponChange. What do I need to add?
-
I'm not 100% certain, but player id. 0 may not work for all players in this function. Try SetWeaponActive(1, ...) and see if that works. If so, you'll have to create a var i: byte; and a for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then begin SetWeaponActive(i, 1, false); SetWeaponActive(i, 2, false); SetWeaponActive(i, 3, false); end;
Lol I just realized.. your procedure name is SetWeaponActive as well, and I don't think you cave have multiple of the same procedure with the same name.
-
ie just try this:
procedure RestrictWeapons();
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;
and call this RestrictWeapons() procedure in onweaponchange or wherever you want it to be called
-
ie just try this:
procedure RestrictWeapons();
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;
and call this RestrictWeapons() procedure in onweaponchange or wherever you want it to be called
So how I call RestrictWeapons() in OnWeaponChange() ?
-
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte); begin RestrictWeapons; end;
-
The whole code should look like this:
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
RestrictWeapons;
end;
procedure RestrictWeapons();
begin
SetWeaponActive(0,1,false);
SetWeaponActive(0,2,false);
SetWeaponActive(0,3,false);
end;
or
var
i: Integer;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
RestrictWeapons;
end;
procedure RestrictWeapons();
begin
for i := 1 to 3 do
SetWeaponActive(0,i,false);
end;
-
It said RestrictWeapons() is not defined.
-
place that procedure above OnWeaponChange
-
place that procedure above OnWeaponChange
Thank you it works now!
--Edit--
But how can we disable when player join?
-
place that procedure above OnWeaponChange
Thank you it works now!
--Edit--
But how can we disable when player join?
put it in onjointeam. But since you disable the weapons for everyone (ID 0), i'd just put it in activateserver ::)
-
But since you disable the weapons for everyone (ID 0), i'd just put it in activateserver ::)
Then I'd change soldat.ini
-
Then I'd change soldat.ini
way better.
-
Well I just want to enabled it back when it gets * kills.
-
then tell us exactly what you want and we'll tell you how, or we'll make it.
-
procedure Activateserver;
var
i: Integer;
begin
for i := 1 to 3 do //Might wanna change to 10?
SetWeaponActive(0,i,false);
end;
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
If GetPlayerStat(Killer,'Kills') > 1 then SetWeaponActive(0,1,true);
If GetPlayerStat(Killer,'Kills') > 2 then SetWeaponActive(0,2,true);
//etc. etc, i suggest using ">", if its used on CTF mode
end;
-
then tell us exactly what you want and we'll tell you how, or we'll make it.
What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.
-
then tell us exactly what you want and we'll tell you how, or we'll make it.
What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.
k, ill do it.
EDIT: this huge code should do the trick, but it seems that in doesn't works for soldat...
var
i, b: Integer;
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if GetPlayerStat(Killer,'Kills') in [11..20] then begin //If kill amount is needed
for i := 1 to 10 do //To call all weapons inactive
SetWeaponActive(Killer,i,false); //Set all weapons inactive
SetWeaponActive(Killer,2,true); //Set next weapon active
end; //End block if guy has 11 to 20 kills
if GetPlayerStat(Killer,'Kills') in [21..30] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,3,true);
end;
if GetPlayerStat(Killer,'Kills') in [31..40] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,4,true);
end;
if GetPlayerStat(Killer,'Kills') in [41..50] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,5,true);
end;
if GetPlayerStat(Killer,'Kills') in [51..60] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,6,true);
end;
if GetPlayerStat(Killer,'Kills') in [61..70] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,7,true);
end;
end;
//Damn this turned out in a huge code... fix anyone?
procedure OnJoinTeam(ID, Team: byte);
begin
for b := 2 to 10 do
SetWeaponActive(ID,b,false);
end;
-
then tell us exactly what you want and we'll tell you how, or we'll make it.
What I want is all weapons to be disabled beside the first gun. When they get 10 kills, first gun is disabled and the second gun is enabled then next gun then .etc.
k, ill do it.
EDIT: this huge code should do the trick, but it seems that in doesn't works for soldat...
var
i, b: Integer;
procedure OnPlayerKill(Killer, Victim: byte;Weapon: string);
begin
if GetPlayerStat(Killer,'Kills') in [11..20] then begin //If kill amount is needed
for i := 1 to 10 do //To call all weapons inactive
SetWeaponActive(Killer,i,false); //Set all weapons inactive
SetWeaponActive(Killer,2,true); //Set next weapon active
end; //End block if guy has 11 to 20 kills
if GetPlayerStat(Killer,'Kills') in [21..30] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,3,true);
end;
if GetPlayerStat(Killer,'Kills') in [31..40] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,4,true);
end;
if GetPlayerStat(Killer,'Kills') in [41..50] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,5,true);
end;
if GetPlayerStat(Killer,'Kills') in [51..60] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,6,true);
end;
if GetPlayerStat(Killer,'Kills') in [61..70] then begin
for i := 1 to 10 do
SetWeaponActive(Killer,i,false);
SetWeaponActive(Killer,7,true);
end;
end;
//Damn this turned out in a huge code... fix anyone?
procedure OnJoinTeam(ID, Team: byte);
begin
for b := 2 to 10 do
SetWeaponActive(ID,b,false);
end;
That is alot. One question tho, what you mean [51..60]?
-
That is alot. One question tho, what you mean [51..60]?
I believe the left part must be between (inclusivly) 51 and 60. But I can't say this for certain.
Replacement for the in operator as a function i guess
function WithinInt(const Value, Low, High: integer): boolean;
begin
Result := (Value >= Low) and (Value <= High);
end;
For other types, simply change the time (and preferably the function name; wouldn't be appropiate to leave Int at the end if its for doubles)
-
const Kills4Weap=2;
procedure SetWeapons(ID: byte);
var i: byte;
begin
for i:= 1 to 10 do SetWeaponActive(ID,i,false);
SetWeaponActive(ID, (((GetPlayerStat(ID,'Kills') div Kills4Weap) mod 10) + 1), true);
end;
Call it in OnPlayerKill and OnJoinTeam.
-
if GetPlayerStat(Killer,'Kills') in [11..20] then begin
Just a question, what is 'in', does it check if one of the arrays is the number of kills, because iv'e never heard about that.
-
if the number of kills is into these numbers, it will do something.
-
Thanks for answer. Sounds quite helpfull.
-
Can we create a procedure or function?
Like this...
function OnCommand(ID: Byte; Text: string): boolean;
begin
Result := false;
MyProcedure;
end;
procedure MyProcedure(Text: string; ID: byte);
begin
if MaskCheck(Text, '/alpha') then Command('/setteam1 '+INTTOSTR(ID) );
// Just an example...
end;
-
You must call it like you declare.
For:
procedure MyProcedure(Text: string; ID: byte);
Example:
MyProcedure(Text, ID);
-
Also note that functions/procedures you make bust be declared/defined above where you want to call them. So in the example, above OnCommand u can say what MyProcedure is.