Author Topic: Scripting Engine Suggestions  (Read 25568 times)

0 Members and 2 Guests are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting Engine Suggestions
« Reply #100 on: September 30, 2007, 07:29:18 am »
onchangeteam?
OnJoinTeam event
You can detect if it is an actual "changing team" or first time joining through setting and checking a variable..

Offline freestyler

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 326
Re: Scripting Engine Suggestions
« Reply #101 on: September 30, 2007, 10:13:19 am »
GetPlayerStat(ID, 'Admin') - boolean, returns true if player is admin

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Scripting Engine Suggestions
« Reply #102 on: September 30, 2007, 10:44:08 am »
Events:
OnKickVoteCast(voter,victim: byte; reason: string);

OnMapVoteCast(voter: byte; mapname: string);

function OnVoteEnd(): boolean;
result:=true makes the vote have no effect
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting Engine Suggestions
« Reply #103 on: September 30, 2007, 02:11:46 pm »
OnVoteEnd(): boolean;
with a type parameter to know which type ended.
i dont know exactly how the voting works and if 2 votes can run side-by-side at the same time or anything if its only one at a time or what...

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Scripting Engine Suggestions
« Reply #104 on: September 30, 2007, 05:05:45 pm »
DorkeyDear already suggested it, but

SetPlayerDeaths( ID, integer )

would come in handy a lot.
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Scripting Engine Suggestions
« Reply #105 on: September 30, 2007, 06:17:19 pm »
Events:
OnKickVoteCast(voter,victim: byte; reason: string);

OnMapVoteCast(voter: byte; mapname: string);

function OnVoteEnd(): boolean;
result:=true makes the vote have no effect

shouldn't the first two be booleans instead of last one? then both could run @ same time and there would be no mix up

example:
Code: [Select]
procedure OnVoteKickCast(Voter, Victim: byte; Reason: string):boolean;
begin
  Result:=true //return false to continue with kick/map vote
  *custom vote stuff*
  if *time var* = 0 and *vote var* = # then KickPlayer(Victim);
  else *wutever*
end;
« Last Edit: October 01, 2007, 06:17:34 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Scripting Engine Suggestions
« Reply #106 on: October 01, 2007, 10:29:38 am »
without SetPlayerDeaths( ID, integer ) there is no other way around i guess sai`ke?

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Scripting Engine Suggestions
« Reply #107 on: October 01, 2007, 08:40:03 pm »
how about:

function StringExists(str:string):boolean;

returns true if the string exists

Example:
Code: [Select]
function OnCommand(ID:Byte;Text:string):boolean;
begin
  *blah blah blah*
    if StringExists(GetPiece(Text, ' ', 2)) then *do this*
    else *do this*
  *blah blah blah*
end;

if my else use is incorrect, correct me. please.
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Aquarius

  • Soldier
  • **
  • Posts: 234
Re: Scripting Engine Suggestions
« Reply #108 on: October 02, 2007, 02:33:06 am »
A function to get Unix Time (number of seconds elapsed since 1970).

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting Engine Suggestions
« Reply #109 on: October 02, 2007, 04:27:05 pm »
OnPlayerKill should be called BEFORE the player gets damaged.. I've been trying to get the person's vest amount when they died, but i got some really low negative number :P

Date Posted: October 02, 2007, 04:21:08 pm
Functions:
I woke up this morning thinking about this one.
GetPlayerStat(#,'Stance'): byte;
When standing, result is 0; when crouching, result is 1; when proning (sp?), result is 2; or whatever you wish it to be if this is implemented.

GetPlayerStat(#,'Time'): integer;
I suggest having it tell the time in seconds. I think showing this in seconds would be much more helpful to people than minutes. Same with the GetObjectStat for Time, if that is going to be implemented.

Global variable thingy muh-bobber
Pause...
0 = not paused
1 = paused

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Scripting Engine Suggestions
« Reply #110 on: October 02, 2007, 08:08:49 pm »
maybe there should be a:
function GetServerStat(IP: string; Port: integer; Stat: string);

so you can check:
Quote from: possible new function
Stats:
Name - string ----- Server name
Map - string ----- Current map playing
connection - integer ----- 0 for LAN, 1 for internet
Players - integer ----- Current players
Maxp - integer ----- max players
Gpass - string ----- Game password, not admin pass
APass - string ----- Returns asterics (*) for each letter in pass, doesn't return actual pass (maybe return pass if safe mode off?)
Passworded - boolean ----- password needed?
ClanMatch - boolean ----- clan match enabled?
Greet1, Greet2, Greet3 - string ----- Greeting messages
Balance - boolean ----- balance teams?
maxvote - single ----- vote percent
minping - integer ----- minimum ping limit
maxping - integer ----- maximum ping limit
Dedicated - boolean ----- Dedicated server?
Lobby - string ----- lobby registered in (ip or http string)
Respawn - single ----- respawn time
bonuses - string ----- bonuses allowed (string in 5 parts (F P B V C) inactive(0) or active(1))
freq - integer ----- bonus frequency (1 to 5)
bots - integer ----- number of bots
FFire - boolean ----- friendly fire?
loop - boolean ----- loop maps?
style - integer ----- game mode (same as const's in default script "core")
weapons - string ----- active weaps (same format as bonuses but 14 parts (DD HK AK SA SZ RG 79 BT MM MG US CK CS 72) 0 or 1)
nades - integer ----- max nades
limit - integer ----- score limit
statgun - boolean ----- stat guns?
RSA - string ----- (same as weaps and bonuses, 3 parts (R S A) 0 or 1)
Aamt - integer ----- Advance mode amount

and anything else you can find server-side in soldat.ini and server.ini

*hint hint*
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Scripting Engine Suggestions
« Reply #111 on: October 04, 2007, 12:05:07 am »
A function to get Unix Time (number of seconds elapsed since 1970).

If you want this to calculate intervals with more accuracy than a seconds, you can use FormatDate. I'm using this in a script:

Code: [Select]
function GetTimeSeconds(): single;
var
arr: TStringArray;
hours, minutes, seconds, milliseconds: integer;
begin
arr := xsplit(FormatDate('h:n:s:z'), ':');

hours := StrToInt(arr[0]);
minutes := StrToInt(arr[1]);
seconds := StrToInt(arr[2]);
milliseconds := StrToInt(arr[3]);

Result := hours * 3600.0 + minutes * 60.0 + seconds + milliseconds/1000.0;
end;

function GetSecondsInterval(seconds1, seconds2: single): single;
begin
if seconds2 < seconds1 then
seconds2 := seconds2 + 24 * 3600.0;
Result := seconds2 - seconds1;
end;

function StringExists(str:string):boolean;

I'm not sure if i got your idea right, but i think you can use StrPos for that, like this:
Code: [Select]
if StrPos('lala', str) > 0 then OhYeah();

Might I suggest a change in the WriteFile function, if it's possible. I think it's pretty useless as it is right now, each time i use it i get weird characteres in the written file. I want it to overwrite the file. Or maybe a DeleteFile would help.
urraka

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Scripting Engine Suggestions
« Reply #112 on: October 04, 2007, 09:11:42 pm »
Quote from: Unfinished note in UpdateVars()
NOTE: If you change a variable, this function will not set it! This just refreshes the

Syntax Example:   

refreshes the what?

(needs to be fixed)

Date Posted: October 04, 2007, 07:57:23 pm
GetPlayerStat(ID, 'Admin') - boolean, returns true if player is admin

how about a makeshift one?

Code: [Select]
var
  Admin: array[1..32] of boolean;

function OnPlayerCommand(ID:Byte;Text:string):boolean;
var
  Temp1, Temp2, Temp3: string;
begin
  Result:=false;
  Temp1:=GetPiece(LowerCase(Text), ' ', 0);
  Temp2:=GetPiece(Text, ' ', 1);
  Temp3:=ReadINI('soldat.ini','NETWORK','Admin_Password','  ');
  if (Temp1 = '/adminlog') then begin
    if (Temp2 = Temp3) then begin
      Admin[ID]:=true;
      if (Tries[ID] > 0) then Tries[ID]:=0;
    end;
    if ((Temp2 = Temp3) = false) then begin
      if (Tries[ID] = 0) then begin
        Result:=true;
        DrawText(ID,'Tries: 3',200,$FFFFFFFF,0.50,30,190);
        SayToPlayer(ID,'Password incorrect, try correct case.');
        Tries[ID]:=Tries[ID]+1;
        exit;
      end;
      if (Tries[ID] = 1) then begin
        Result:=true;
        DrawText(ID,'Tries: 2',200,$FFFFFF20,0.50,30,190);
        SayToPlayer(ID,'Password incorrect, are you spelling it right?.');
        Tries[ID]:=Tries[ID]+1;
        exit;
      end;
      if (Tries[ID] = 2) then begin
        Result:=true;
        DrawText(ID,'Tries: 1',200,$FFFF8020,0.50,30,190);
        SayToPlayer(ID,'Password incorrect, one more incorrect try and you will be kicked.');
        Tries[ID]:=Tries[ID]+1;
        exit;
      end;
      if (Tries[ID] = 3) then begin
        DrawText(ID,'Tries: 0',200,$FFFF2020,0.50,30,190);
        SayToPlayer(ID,'Password incorrect, apparently you do not have the password and will be kicked.');
        Sleep(90);
        KickPlayer(ID);
      end;
    end;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  Admin[ID]:=false;
  if (Tries[ID] > 0) then Tries[ID]:=0;
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
  if Admin[ID] then Admin[ID]:=false;
  if (Tries[ID] > 0) then Tries[ID]:=0;
end;

just something I cooked up, not a custom function, as I don't know how to make one like this, but it get's the job done (even though you are only setting a boolean for a certain player)

if someone could translate this into function-form they can go right ahead ;)

Date Posted: October 04, 2007, 08:07:20 pm
suggestion:

Variable:
  Maplist: string;
returns current map list

needed very much...
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Scripting Engine Suggestions
« Reply #113 on: October 04, 2007, 10:32:38 pm »
Sigh.... too many lazy nub suggestions.

Eg: Get current maplist = ReadFile('mapslist.txt');

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Scripting Engine Suggestions
« Reply #114 on: October 04, 2007, 11:28:23 pm »
Another little errors on the manual... in GetObjectStat and GetSpawnStat it says

Quote
This function will return some information about the specified player (ID).


Btw, thanks for adding stuff in the scripting engine. Some of the things you've added recently have been very usefull. EnEsCe.karma++;
urraka

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting Engine Suggestions
« Reply #115 on: October 06, 2007, 07:42:28 am »
Can you have it so when you get somebody's ammo through GetPlayerStat, and if they are reloading... it returns -1 and a new GetPlayerStat thing for the % or something of reload completedness?
i would assume its client side, but worth asking for :)

Offline Aquarius

  • Soldier
  • **
  • Posts: 234
Re: Scripting Engine Suggestions
« Reply #116 on: October 06, 2007, 09:41:58 am »
function HighestPlayerID(): byte

It would return the ID of the player/bot with the highest ID on the server.
It would be very convenient for loops.
« Last Edit: October 06, 2007, 09:44:59 am by Aquarius »

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Scripting Engine Suggestions
« Reply #117 on: October 06, 2007, 09:08:48 pm »
Sigh.... too many lazy nub suggestions.

Eg: Get current maplist = ReadFile('mapslist.txt');

I mean it is the filename of the maplist the server is using at that moment (or any)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Scripting Engine Suggestions
« Reply #118 on: October 06, 2007, 09:32:34 pm »
Sigh.... too many lazy nub suggestions.

Eg: Get current maplist = ReadFile('mapslist.txt');

I mean it is the filename of the maplist the server is using at that moment (or any)
if that is done, then to be fair with all the other files u can manually load, u would have to have a variable to soldat.ini, weapons.ini, and all the other "currently being used" files..
u could just script it to copy the text a person did with using the command to change the file and put that into a string (and if u want it to work after a /recompile, in a file or something that is loaded on the ActivateServer event)

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Scripting Engine Suggestions
« Reply #119 on: October 06, 2007, 10:30:24 pm »
I mean it is the filename of the maplist the server is using at that moment (or any)
There is a reason commands like "/loadlist newlist.txt" get passed to OnAdminCommand.
So you can do things YOURSELF.

Only way to change current map list txt name is by that command, so therefore you can figure it out yourself by checking it in OnAdminCommand.