Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: |_ancer on September 07, 2009, 03:46:52 am
-
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var allplayersdie : byte;
dmgamount : integer;
temps : string;
begin
if pos('/dmg ',temps) = 1
then begin
temps := Text;
temps := delete(temps,1,5);
dmgamount := strtoint(temps);
for allplayersdie := 1 to NumPlayers do
DoDamage(allplayersdie, dmgamount)
end
end;
I cannot find anything wrong in the script and it just won't compile. It keeps on saying 'Type mismatch'. Help!
-
Delete is a procedure that works by reference; it does thus not return a value, but instead modifies the string itself.
tl;dr change temps := delete(temps,1,5); to delete(temps,1,5);.
-
09-09-07 21:09:13 - DeathDmg -> [Error] (10:9): Identifier expected
It says that when I changed it.
-
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
allplayersdie : byte;
dmgamount : integer;
temps : string;
begin
if pos('/dmg ', temps) = 1 then begin
temps := Text;
Delete(temps, 1, 5);
dmgamount := strtoint(temps);
for allplayersdie := 1 to NumPlayers do
DoDamage(allplayersdie, dmgamount)
end
end;
-
It compiles but whenever I do /dmg 4000, it doesn't seem to kill anyone.
-
You check if temps = /dmg before you set the value, change pos('/dmg ', temps) to pos('/dmg ', Text). Second thing is that it would be better if you use Copy(Text, 1, 5) instead of Pos.
-
if GetPiece(text,' ',0) = '/dmg' then try
DoDamage(IntToStr(GetPiece(text,' ',1)), IntToStr(GetPiece(text,' ',2)));
except
WriteConsole(ID,'/dmg <id> <dmg>',$AA0000);
end;