Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: y0uRd34th on December 23, 2008, 06:20:16 am
-
Frist Hi :)
How can i connect this "Example" Script that it works?
Always if I start my Server it crashes and I don't know whats wrong there:
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text = '!kill' then begin
DoDamage(ID,4000);
end;
end;
begin
if Text = '!heal' then begin
DoDamage(ID,-4000);
end;
end;
If i delete the second Part with !heal it works fine but when i add it... nothing works!
-
There's one "end;" in there that's a bit misplaced:
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text = '!kill' then begin
DoDamage(ID,4000);
end;
if Text = '!heal' then begin
DoDamage(ID,-4000);
end;
end;
-
Ahh Fine :) thank you and another Question how can i do this Code Thing with the Script in it?
-
Ahh Fine :) thank you and another Question how can i do this Code Thing with the Script in it?
You're going to need to be a bit more specific here...
If you just want to know how to install a script: http://forums.soldat.pl/index.php?topic=21468.0 is your best guide.
-
I know how to Install Scripts! But i dont know how to do some Scripting things and so...
And now my Server is 9999PING too omfg! Now im at the End of My Live^^
-
And now my Server is 9999PING too omfg! Now im at the End of My Live^^
http://forums.soldat.pl/index.php?topic=21869.0
-
Yes i know but the Problem is that sometimes work :/ and sometimes not :P and i get always another IP to join in Soldat by the Server xD
EDIT:
CreateBullet(GetPlayerStat(1,'x'), GetPlayerStat(1,'y') - 500, 0, 0,100, 2, 1);
function CreateBullet(X, Y, VelX, VelY, HitM: single; sStyle, Owner: byte): integer;
GetPlayerStat(1,'x'), GetPlayerStat(1,'y') this is X, Y?
And What do HitM (Single): Hit Multiplier??
velX and VelY is the Position of the bullet where it spawns right?
Ok Edit again^^
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/fireshield' then begin
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 65, 0, 0,100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') - 65, 0, 0,100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 0, - 65, 0,100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y') 0, 65, 0,100, 5, 1);
end;
end;
what's wrong now? :P
-
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 65, 0, 100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 65, 0, 100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 65, 100, 5, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 65, 100, 5, 1);
Try that. You were missing commas after "GetPlayerStat(ID,'y')" on each line, and you also had too many arguments then if that was fixed up. It should work as intended now.
Be cautious of syntax errors. Also, it's worth checking what error the compiler gives you, as it's usually pretty precise in what needs to be fixed up.
p.s. I noticed your error seems to have come about from copying the example. I'm going to quote what iDante said in another thread.
Don't trust any of the examples on that page, figure them out yourself. Same goes for any of those functions really.
:P
-
Thanks again. How can i add to this /heal script that i can write ID's which i want to heal like /heal 4 for Player4 ??? i'm not sure but i think that is some with get Piece or so :P can u say me how?
if Text = '/heal' then begin
DoDamage(ID,-4000);
end;
-
Thanks again. How can i add to this /heal script that i can write ID's which i want to heal like /heal 4 for Player4 ??? i'm not sure but i think that is some with get Piece or so :P can u say me how?
if Text = '/heal' then begin
DoDamage(ID,-4000);
end;
if GetPiece(Text,' ',0) = '/heal' then begin
DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
end;
UNTESTED
-
I realy "love" the People in this Forum ;D Thanks iDante, works great =)
But next Question if i do "porecedure OnPlayerCommand" or "OnCommand" the other Commandos like "/kill" or "/addbot" not work, do someone know how i can correct this ???
-
Did you put result := true inside? If you did, change it to false.
-
I don't have any result := true in it should i add it with false?
-
I don't have any result := true in it should i add it with false?
Yes, give that a shot.
-
procedure OnPlayerCommand(ID: Byte; Text: string);
begin
if GetPiece(Text,' ',0) = '/heal' then begin
DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
end;
if Text = '/boom' then begin
DoDamage(ID,5000)
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 0, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 0, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, 6, 100, 4, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, -6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 3, 100, 4, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, -3, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 3, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 3, 100, 4, 0);
end;
end;
Where have i to put it? If i put it before the last "end;" it works not ???
-
procedure OnPlayerCommand(ID: Byte; Text: string);
begin
if GetPiece(Text,' ',0) = '/heal' then begin
DoDamage(strtoint(GetPiece(Text,' ',1)),-4000);
end;
if Text = '/boom' then begin
DoDamage(ID,5000)
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 0, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 0, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 0, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, 6, 100, 4, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, -6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 3, - 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 3, 6, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, 3, 100, 4, 1);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, -3, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), 6, - 3, 100, 4, 0);
CreateBullet(GetPlayerStat(ID,'x'), GetPlayerStat(ID,'y'), - 6, 3, 100, 4, 0);
end;
result := false;
end;
Or at very top, right after begin;. Whatever floats your boat!
-
[ERROR] (27:6): Unknown identifier 'result'
:( What's now worng?
-
Oh, I see - you've somehow declared OnPlayerCommand as a procedure, and not a function. Sorry for not spotting that off the bat.
I.e, change:
procedure OnPlayerCommand(ID: Byte; Text: string);
Into:
function OnPlayerCommand(ID: Byte; Text: string): boolean;
-
Thank you, =) it works fine :D
How can i do that if the "playername=xxx" is right that he gets every 20seconds an bsk ???
So much i have :P
procedure AppOnIdle(Ticks: integer);
begin
if Ticks mod (60 * 20) = 0 then begin
if ?playername?
givebonus(?,2);
end;
end;
end;
-
procedure AppOnIdle(Ticks: integer);
var
i: integer;
X, Y: single;
begin
if (Ticks mod (60 * 20) = 0) then
begin
for i:= 1 to 32 do
begin
if (IDToName(i) = 'xxx') then
begin
GetPlayerXY(i, X, Y);
SpawnObject(X, Y, 21);
end;
end;
end;
end;
Have fun!
-
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if GetPlayerStat(i, 'Active') = true then
if GetPlayerStat(i, 'Name') = 'xxx' then
SpawnObject(GetPlayerStat(i, 'X'), GetPlayerStat(i, 'Y'), 21);
end;
Another way to do it. Either way you go with, make sure you check that the player is active.
-
The best way to do it is using givebonus(id,style).
style:
pred: 1
bers: 2
vest: 3
nade: 4
cluster: 5
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if GetPlayerStat(i, 'Active') then
if IDToName(i) = 'xxx' then
GiveBonus(i,2);
end;
-
Oh wow so much exaamples:P :D Thanks again :)
And do someone have an MoneySystem or so? You don't must write the script but if u have one plz Post ;)
-
The best way to do it is using givebonus(id,style).
style:
pred: 1
bers: 2
vest: 3
nade: 4
cluster: 5
procedure AppOnIdle(Ticks: Integer);
var i: Byte;
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if GetPlayerStat(i, 'Active') then
if IDToName(i) = 'xxx' then
GiveBonus(i,2);
end;
Hmm, never saw that GiveBonus() function on enesce.com/help/ before, just wondering :)
-
Do no guy have an "Money System" ???
-
Hmm, never saw that GiveBonus() function on enesce.com/help/ before, just wondering :)
Don't trust that website until it gets fixed.
For more functions look at the soldat devs wiki (google it) as well as the to do list on that wiki.
-
procedure ActivateServer();
var
bsk: boolean;
begin
bsk:=false;
WriteLn('Berserker Off');
end;
procedure AppOnIdle(Ticks: Integer);
var
i: Byte;
bsk: boolean;
begin
if Ticks mod (60 * 10) = 0 then
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
end;
procedure OnPlayerRespawn(ID: byte);
var
i: Byte;
bsk: boolean;
begin
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
bsk: boolean;
begin
if Text = '/bsk' then begin
if bsk=false then begin
bsk:=true;
WriteLn('Berserker On');
end
else
begin
bsk:=false;
WriteLn('Berserker Off');
end;
end;
Result := false;
end;
Idk why but it won't work, the Server starts but the Script won't work right!? ???
-
Just from first impressions: make bsk global.
-
What do u mean with "global"?
-
then you put it above the functions/procedures so the variable will count for each and every function/procedure.
What you do now is make bsk a variable in procedure activate server and another one in procedure apponidle.
They are both different from eachother and not the same variable.
Hope this helps spkka
-
var
bsk: boolean;
procedure ActivateServer();
begin
bsk:=false;
WriteLn('Berserker Off');
end;
procedure AppOnIdle(Ticks: Integer);
var
i: Byte;
begin
if Ticks mod (60 * 10) = 0 then
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
end;
procedure OnPlayerRespawn(ID: byte);
var
i: Byte;
begin
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then begin
if bsk=false then begin
bsk:=true;
WriteLn('Berserker On');
end
else
begin
bsk:=false;
WriteLn('Berserker Off');
end;
end;
Result := false;
end;
So? :P
-
var
bsk: boolean;
pre: boolean;
procedure ActivateServer();
begin
bsk:=false;
pre:=false;
end;
procedure AppOnIdle(Ticks: Integer);
var
i: Byte;
begin
if Ticks mod (60 * 10) = 0 then
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if pre=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
procedure OnPlayerRespawn(ID: byte);
var
i: Byte;
begin
for i := 1 to 32 do
if bsk=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
for i := 1 to 32 do
if pre=true then
if GetPlayerStat(i, 'Active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then begin
if bsk=false then begin
bsk:=true;
end
else
begin
bsk:=false;
end;
end;
begin
if Text = '/pre' then begin
if pre=false then begin
pre:=true;
end
else
begin
pre:=false;
end;
end;
Result := false;
end;
Now i added the same with Predator but it only says Error (30:1) line30 but what means the 1??
-
Responding the the non-predator thing:
A couple stylistic things, because I don't want to go in-depth right now.
1. =true
if bsk=true then ...;
if bsk=false then ...;
Are very horrid and evil. Use this instead:
if bsk then ...;
if not bsk then ...;
2. for loop then boolean check?
for i := 1 to 32 do
if bsk=true then ...;
You do this several times. First check 1 (get rid of =true), then move the boolean outside of the for loop. Will look like this.
if bsk then
for i := 1 to 32 do ...;
3. Dealio with GetPlayerStat(i, 'active'). Unfortunately, for this one you have to add in = true, or it doesn't work out right.
And the 1 in the predator thing means that it is on column one in the line, or character 1.
Edit: comon man... copy-paste and programming can lead to bad things if you're not careful. Notice the extra begin in AppOnIdle? And just about everywhere? If your compiler gives you an error, LOOK FOR IT.
-
3. Dealio with GetPlayerStat(i, 'active'). Unfortunately, for this one you have to add in = true, or it doesn't work out right.
GetPlayerStat(id,'active') works without = true.
You have to add = true to GetPlayerStat(id,'alive').
-
var
bsk: boolean;
pre: boolean;
procedure ActivateServer();
begin
not bsk;
not pre;
end;
procedure AppOnIdle(Ticks: Integer);
var
i: Byte;
begin
if Ticks mod (60 * 10) = 0 then
for i := 1 to 32 do
if bsk then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if pre then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
procedure OnPlayerRespawn(ID: byte);
var
i: Byte;
begin
for i := 1 to 32 do
if bsk then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
for i := 1 to 32 do
if pre=true then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then begin
if not bsk then begin
bsk;
end
else
begin
not bsk;
end;
end;
begin
if Text = '/pre' then begin
if not pre then begin
pre:=true;
end
else
begin
not pre;
end;
end;
Result := false;
end;
Ok then? :D Now it's saying Error(7:6) But ehm? "not pre;" what's there wrong? Please Help Guys :-\
-
Remove the "not" things at the beginning , use " := false" instead
procedure ActivateServer();
begin
bsk:=false;
pre:=false;
end;
-
There's still begin's in the middle of procedures, loops in OnPlayerRespawn and a lot of overcomplicated code... Only the begins will be a real problem though. Also, he changed Active to Alive... That's not really gonna help.
And please,
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then bsk := not bsk;
if Text = '/pre' then pre := not pre;
end;
-
But if I do
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then bsk := not bsk;
if Text = '/pre' then pre := not pre;
end;
then i can only turn off the bsk or pred :/ or not?
-
if Text = '/pre' then pre := not pre;
If bsk is true, it will set it to not true = false.
If bsk is false, it will set it to not false = true.
pre := (1 > 0); // pre is true
pre := not (5 = 5); // pre is false
pre := 'This' <> 'That'; // pre is true
-
var
bsk: boolean;
pre: boolean;
procedure ActivateServer();
begin
bsk:=false;
pre:=false;
end;
procedure AppOnIdle(Ticks: Integer);
var
i: Byte;
begin
if Ticks mod (60 * 10) = 0 then
for i := 1 to 32 do
if bsk then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
if Ticks mod (60 * 20) = 0 then
for i := 1 to 32 do
if pre then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
procedure OnPlayerRespawn(ID: byte);
var
i: Byte;
begin
for i := 1 to 32 do
if bsk then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,2);
begin
for i := 1 to 32 do
if pre=true then
if GetPlayerStat(i, 'Alive') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
GiveBonus(i,1);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/bsk' then bsk := not bsk;
if Text = '/pre' then pre := not pre;
end;
Error (30:1) Identifier expected...
var
wtf?
Slowly i give it up to bring it working...
-
if GetPlayerStat(i, 'Alive') then
change to
if GetPlayerStat(i, 'Alive') = true then
-
Done, already Error in 30:1 [ :'(?]
-
As I said before, you put "begin" in the middle of procedures. It gives an Indentifier expected error because you're declaring a procedure in another procedure.
-
Ahh now I check!!! :P Working wtf I check things faster if i have Examples^^ :D:D
-
var
bsk: boolean;
pre: boolean;
procedure gb;
var i: byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
if bsk then
GiveBonus(i,2)
else
if pre then
GiveBonus(i,1);
end;
procedure AppOnIdle(Ticks: Integer);
begin
gb;
end;
procedure OnPlayerRespawn(ID: byte);
begin
var
gb;
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
case lowercase(Text) of
'/bsk': bsk := true;
'/bsk off': bsk := false;
'/pre': pre := true;
'/pre off': pre := false;
end;
Error 26:1 (var gb;)
And don't need "procedure AppOnIdle" "if Ticks mod (60 * x) = 0 then begin"?
-
var
bsk: boolean;
pre: boolean;
procedure gb;
var i: byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if IDToName(i) = '-=]SH[=- y0uRd34th' then
if bsk then
GiveBonus(i,2)
else
if pre then
GiveBonus(i,1);
end;
procedure AppOnIdle(Ticks: Integer);
begin
if Ticks mod (60 * 20) = 0 then
gb;
end;
procedure OnPlayerRespawn(ID: byte);
begin
gb;
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
case lowercase(Text) of
'/bsk': bsk := true;
'/bsk off': bsk := false;
'/pre': pre := true;
'/pre off': pre := false;
end;
end;
its because you used code before i edited the post with mistake.
You dont need if tick mod because givebonus doesnt spawn a kit.
-
Thanks works fine :D
var bos: boolean;
okh: boolean;
procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
if bos then
givebonus(ID,3);
end;
procedure OnFlagReturn(ID, TeamFlag: byte);
begin
if bos then
givebonus(ID,4);
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
if bos then
givebonus(ID,5);
givebonus(ID,2);
end;
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
if okh then
DoDamage(ID,-20);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
case lowercase(Text) of
'/okh': hok := true;
'/okh off': hok := false;
'/bos': bos := true;
'/bos off': bos := false;
end;
Result := false;
end;
There's all right because it says Error(27:15) unknown Identifier 'ID'
How to fix?
(Don't wonder about okh=onplayerkillheal and bos=bonusonscore :D^^)
-
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
if okh then
DoDamage(ID, -20);
end;
There's no ID in OnPlayerKill. You want Killer in DoDamage.
Also, your script will not work as intended. If you do an if without begin/end, it will only do the next thing before a semicolon ( ; ).
procedure OnFlagScore(ID, TeamFlag: byte);
begin
if bos then
givebonus(ID,5);
givebonus(ID,2);
end;
Will do GiveBonus(ID, 5); if bos is true but will ALWAYS do GiveBonus(ID, 2);
-
Thanks :) working
-
Ok wanna do that if a Player dies the M79 bullet Explodes...
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
i := CreateBullet(GetPlayerStat(Victim,'x'), GetPlayerStat(Victim,'y'), 0, 0, 0,100, 2, Victim);
???I don't know how to let it Explode???
end;
Thank for Answers :D
-
Need an Function procedure whatever to let Explode M79 which spawned by CreateBullet in sky ;D PLZ HELP!!!!! KillObject DONT work!
-
It has to hit something or someone to explode.
And don't triple post. Use the (http://static.forums.soldat.pl/Themes/sfv2/images/english/modify.gif) button.
-
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
And that with "It has to hit something or someone to explode." I know but wanna do it that it bursts in the "Sky"...
-
Use createbullet to spawn it in the sky. It's impossible to make it explode in the sky (as far as I know). Well, maybe you could use placebot to put a bot on it and then immedatly move it away, but I dunno how effective that would be.
-
Hmm [ :( <> :) ] Can us say me the PlaceBot Thing? I've seen it a few days ago but don't find it again :D
-
Hmm [ :( <> :) ] Can us say me the PlaceBot Thing? I've seen it a few days ago but don't find it again :D
http://forums.soldat.pl/index.php?topic=20898.msg372895#msg372895
-
:P thanks but omg bring me not much don't check this script lol can usay me Toumaz how to Explode M79 Bullets in the sky? without hiting Things or Walls etc. ? If not hmm then idk :P
-
:P thanks but omg bring me not much don't check this script lol can usay me Toumaz how to Explode M79 Bullets in the sky? without hiting Things or Walls etc. ? If not hmm then idk :P
Read this again.
Use createbullet to spawn it in the sky. It's impossible to make it explode in the sky (as far as I know). Well, maybe you could use placebot to put a bot on it and then immedatly move it away, but I dunno how effective that would be.
-
Ops thinked impossibel mean possibel, i changed meaning of them^^
-
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
A trick I use is to take the contents of my previous post, delete it, and then make a new post containing the previous post and my new post. Then you avoid double posting and you bump the topic.
-
Yes,Yes EnEsCe, i know :D sry about Triple Post :D But do someone see it the "new" if i modify Post?
A trick I use is to take the contents of my previous post, delete it, and then make a new post containing the previous post and my new post. Then you avoid double posting and you bump the topic.
smart lil' bugger :)
you could spawn a bot there at the position of the m79 and then respawn it elsewhere / kick it; not sure how smooth it could come out to be though
-
procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
for i := 1 to 32 do
if Ticks mod (60 * 20) = 0 then
givebonus(i,1);
end;
procedure OnPlayerRespawn(ID: byte);
begin
givebonus(ID,1);
ForceWeapon(ID,13,14,0);
end;
procedure ActivateServer();
var w: Byte;
begin
for w := 1 to 14 do
SetWeaponActive(0,w,false);
end;
AppOnIdle is workingfine but OnPlayerRespawn is not giving me Predator or Law&Saw...
And SetWeaponAktive si too not working :(
Please Help idk why
-
it looks like you cant give a bonus while respawn. Use this:
var
cooldown: array [1..32] of byte;
just_resp: array [1..32] of boolean;
procedure AppOnIdle(Ticks: integer);
var i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);
cooldown[i] := 20;
if just_resp[i] then
begin
ForceWeapon(i,13,14,0);
just_resp[i] := false;
end;
end;
end;
procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
just_resp[id] := true;
end;
procedure ActivateServer();
var w: Byte;
begin
for w := 1 to 14 do
SetWeaponActive(0,w,false);
end;
edit1
setweaponactive in this script works for me. Disables all weapons in menu.
-
Thanks again ;) but do u know why
procedure ActivateServer();
var w: Byte;
begin
for w := 1 to 14 do
SetWeaponActive(0,w,false);
end;
SetWeaponActive not work?
-
Because SetWeaponActive is not a permanent modification. You must tell each client as they join that all weapons are disabled.
Basically, any time you call SetWeaponActive it is ONLY affecting players currently in the server.
-
procedure OnJoinGame(ID, Team: byte);
var w: Byte
begin
for w := 1 to 14 do
SetWeaponActive(ID,w,false);
end;
It won't work can you show me an example or what i have to use in this?
-
http://enesce.com/help/html/Functions/SetWeaponActive.html
heh.. ONE SIGN ";" in second line... now it's ok........ should be^^
procedure OnJoinGame(ID, Team: byte);
var w: Byte;
begin
for w := 1 to 14 do
SetWeaponActive(ID,w,false);
end;
-
I know i fixed it already :/ but it won't work, server starts normally no Errors or other things :(
-
well... Or And if it's wrong I don't know...
procedure OnJoinGame(ID, Team: byte);
var WeaponNum: Byte;
begin
for WeaponNum := 1 to 14 do
SetWeaponActive(ID,WeaponNum,false);
end;
-
... Argh! Do no one know how to use it :(!?= argh...
-
Use it in OnJoinTeam...
-
If you are using a CTF match you must use OnJoinTeam. OnJoinGame is only called for Death Match
-
Thanks now it works, but now the weaponmenu is bugged :(, also i want to enable 1gun and if the Player picked it he get's Saw & Law how to do it? I think with GetPlayerStat(ID,Primary) = 1 or so? idk, thanks for answers!
-
Using OnWeapoChange would be better.
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
if PrimaryNum = 1 then
forceweapon(id,15,16,0);
end;
-
Hurraaa!!! Thanks :)
How can i get Players Health and give it him back when he got a Bonus because Bonus heals him :/
-
procedure givebonus2(id,style: byte);
var hp: integer;
begin
hp:=getplayerstat(id,'health');
givebonus(id,style);
if (style=1) or (style=2) then
dodamage(id,getplayerstat(id,'health')-hp);
end;
-
var
cooldown: array [1..32] of byte;
coolbarret: array [1..32] of byte;
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
u: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);
cooldown[i] := 20;
end;
for u := 1 to 32 do
if GetPlayerStat(i,'active') then
if coolbarret[u] > 0 then
coolbarret[u] := cooldown[i] - 1
end;
procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
end;
procedure OnJoinTeam(ID, Team: byte);
var
w: Byte;
begin
for w := 2 to 14 do
SetWeaponActive(ID,w,false);
end;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
if PrimaryNum = 1 then
ForceWeapon(ID,15,16,0);
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
GiveBonus(ID,3);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/barret' then
if coolbarret := 0 then begin
ForceWeapon(ID,8,16,0);
coolbarret[id] := 120;
end;
end;
Result := false;
end;
These lines i added:
u: Byte;
for u := 1 to 32 do
if GetPlayerStat(i,'active') then
if coolbarret[u] > 0 then
coolbarret[u] := cooldown[i] - 1
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/barret' then
if coolbarret := 0 then begin
ForceWeapon(ID,8,16,0);
coolbarret[id] := 120;
end;
end;
Result := false;
end;
Help me please :/
Thanks tk for the thing with HP :)
-
did you add global array coolbarret?
coolbarret[u] := cooldown[i] - 1
perhaps you meant coolbarret[i] := coolbarret[i] - 1
looks like you added one end too many in onplayercommand.
In apponidle you added 2 loops when everything can be done using one
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
begin
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
givebonus(i,1);
cooldown[i] := 20;
end;
if coolbarret[i] > 0 then
coolbarret[i] := coolbarret[i] - 1;
end;
end;
end;
Next time dont post your all fails here, just try to fing bug and fix it. You can chceck in logs/consolelog(latest).txt what is wrong
-
ok thanks for the info about the console log ;) and the script and when the script don't works i often look what can be wrong :/
did you add global array coolbarret?
Yes i did
var
cooldown: array [1..32] of byte;
coolbarret: array [1..32] of byte;
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
hp: integer;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then
begin
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
hp:=GetPlayerStat(i,'health');
GiveBonus(i,1);
DoDamage(i,GetPlayerStat(i,'health')-hp);
cooldown[i] := 20;
end;
-here i think its missing-
if coolbarret[i] > 0 then
coolbarret[i] := coolbarret[i] - 1;
end;
end;
end;
procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
end;
procedure OnJoinTeam(ID, Team: byte);
var
w: Byte;
begin
for w := 2 to 14 do
SetWeaponActive(ID,w,false);
end;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
if PrimaryNum = 1 then
ForceWeapon(ID,15,16,0);
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
GiveBonus(ID,3);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/barret' then
if coolbarret := 0 then begin
ForceWeapon(ID,8,16,0);
coolbarret[id] := 120;
end;
Result := false;
end;
I don't know it's [Error] (26:1): 'BEGIN' expected i think it's in AppOnIdle tryed else begin then begin adn so but don't find the fail... ;/ There are 4ends and 3begins...
-
but don't find the fail... ;/ There are 4ends and 3begins...
begin
begin
begin
end;
end;
end;
there must be ALWAYS the same count of begins and ends
-
Hmm now it's working when i disable the last end; before it was not working then thanks :D
[Error] (54:20): 'THEN' expected
var
cooldown: array [1..32] of byte;
coolbarret: array [1..32] of byte;
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
hp: integer;
begin
for i := 1 to 32 do
if getplayerstat(i,'active') then begin
if cooldown[i] > 0 then
cooldown[i] := cooldown[i] - 1
else begin
hp:=GetPlayerStat(i,'health');
GiveBonus(i,1);
DoDamage(i,GetPlayerStat(i,'health')-hp);
cooldown[i] := 20;
end;
if coolbarret[i] > 0 then
coolbarret[i] := coolbarret[i] - 1;
end;
end;
procedure OnPlayerRespawn(ID: byte);
begin
cooldown[id] := 1;
end;
procedure OnJoinTeam(ID, Team: byte);
var
w: Byte;
begin
for w := 2 to 14 do
SetWeaponActive(ID,w,false);
end;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
if PrimaryNum = 1 then
ForceWeapon(ID,15,16,0);
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
GiveBonus(ID,3);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/barret' then
if coolbarret := 0 then begin
ForceWeapon(ID,8,16,0); //'THEN' expected?
coolbarret[id] := 120;
end;
Result := false;
end;
I read it 3 times...
-
read again, here is mistake if coolbarret := 0 then begin
-
Server says: "
- [Error] Saw'n'Law -> (AppOnIdle): Out Of Range"
That's my AppOnIdle don't know what's going to make the Error :/
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
begin
for i := 1 to 32 do
if barret[i] > 0 then
barret[i] := barret[i] - 60;
if m79[i] > 0 then
m79[i] := m79[i] - 60;
if ammo[i] > 0 then
ammo[i] := ammo[i] - 60;
end;
Any ideas why?
-
Out of range errors mean that you are trying to access a part of an array that doesn't exist. Can I see the whole script?
Edit: just noticed that you forgot begin and end in the for loop.
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
begin
for i := 1 to 32 do begin
if barret[i] > 0 then
barret[i] := barret[i] - 60;
if m79[i] > 0 then
m79[i] := m79[i] - 60;
if ammo[i] > 0 then
ammo[i] := ammo[i] - 60;
end;
end;
Try that out.
-
Thanks that works :)
And thats the whole script:
var
barret: array [1..32] of byte;
m79: array [1..32] of byte;
ammo: array [1..32] of byte;
procedure AppOnIdle(Ticks: integer);
var
i: Byte;
begin
for i := 1 to 32 do begin
if barret[i] > 0 then
barret[i] := barret[i] - 60;
if m79[i] > 0 then
m79[i] := m79[i] - 60;
if ammo[i] > 0 then
ammo[i] := ammo[i] - 60;
end;
end;
procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
if PrimaryNum = 1 then
ForceWeapon(ID,15,16,0);
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
GiveBonus(ID,3);
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
pri,sec: integer;
begin
if Text = '/barret' then
if barret[ID] = 0 then begin
ForceWeapon(ID,8,16,0);
barret[ID] := 7200;
end
if Text = '/m79' then
if m79[ID] = 0 then begin
ForceWeapon(ID,7,16,0);
m79[ID] := 7200;
end
if Text = '/ammo' then
if ammo[ID] = 0 then begin
pri:=GetPlayerStat(ID,'Primary');
sec:=GetPlayerStat(ID,'Secondary');
ForceWeapon(ID,pri,sec,0);
m79[ID] := 3000;
end;
Result := false;
end;
procedure OnJoinTeam(ID, Team: byte);
var
w: Byte;
begin
for w := 2 to 14 do
SetWeaponActive(ID,w,false);
barret[ID] := 0;
m79[ID] := 0;
ammo[ID] := 0;
end;
procedure OnPlayerRespawn(ID: byte);
var
w: Byte;
begin
for w := 2 to 14 do
SetWeaponActive(ID,w,false);
end;
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text = '!help' then begin
SayToPlayer(ID,'"""""""""""""""""""""""""""""');
SayToPlayer(ID,'"Available Commands: "');
SayToPlayer(ID,'"/ammo | get full ammo "');
SayToPlayer(ID,'"/m79 | get M79 "');
SayToPlayer(ID,'"/barret | get Barret "');
SayToPlayer(ID,'"""""""""""""""""""""""""""""');
end;
end;
procedure ActivateServer();
begin
sleep(2000);
Command('/loadwep snl');
end;
How can i load an weapons.ini with script?
Tryed it so:
procedure ActivateServer();
begin
sleep(2000);
Command('/loadwep snl');
end;
Help please :)
-
If you need to wait 2 seconds, use AppOnIdle, not sleep.
-
Ops wanted to delete sleep, testet if it work than if i wait 2seconds or so...
It works fine but the weapon.ini will not load on server :(
Need Help do someone have an Script to Increase Hitpoints for Bots?
I know there is an "Special Bots" Script buti only need it For HP!
Please Help!
-
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.
-
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.
for example result := result/2
then the bot will recive half of the damage that he should recive
-
Ok thanks for Example :) if i get One i check it faster :D
:D Again me^^
OnCommand....(works fine)
if Text = '/cluster' then begin
if Player[ID].Cluster then begin
Player[ID].Cluster := False;
WriteConsole(ID,'Clusterdisabled!',$A10000);
end else begin
Player[ID].Cluster := True;
WriteConsole(ID,'Cluster enabled!',$00A100);
end;
end;
if Text = '/nades' then begin
if Player[ID].Nades then begin
Player[ID].Nades := False;
WriteConsole(ID,'Nade disabled!',$A10000);
end else begin
Player[ID].Nades := True;
WriteConsole(ID,'Nade enabled!',$00A100);
end;
end;
procedure AppOnIdle(Ticks: integer);
var
i, ID: Byte;
begin
for i := 1 to 32 do begin
if PKnova[i] > 0 then
PKnova[i] := PKnova[i] - 1;
if Player[i].Cluster then Clusters(Player[i].Cluster,5);
if Player[i].Nades then GiveBonus(Player[i].Nades,4);
end;
end;
I fail at if Player[i].Cluster then Clusters(Player[i].Cluster,5);
if Player[i].Nades then GiveBonus(Player[i].Nades,4);
this idk how to make that the Player gets the Nades/Clusters then :(
-
try this
if Player[i].Cluster then GiveBonus(i,5);
if Player[i].Nades then GiveBonus(i,4);
-
The best way would be to use OnPlayerDamage. Check if the Victim is a bot, and if so, lower the Result variable.
for example result := result/2
then the bot will recive half of the damage that he should recive
Actually I find that is a bad way to do things.
In theory, it will effectively double the health, but a lot of small amounts of damage will be ignored because of rounding.
It only really badly effects things when you are dividing by larger numbers, but thought I'd throw that nugget of insight out there.
-
@Danmer: Thanks its working never try
GiveBonus(i,5);
:D always used 'ID' or 'Player.Cluster'
@chutem: How would you do it?
Thanks for Answers :D