Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: elMorvano on April 06, 2014, 09:18:14 am

Title: Change map
Post by: elMorvano on April 06, 2014, 09:18:14 am
* Is it possible to disable votemap by ESC>Change a map??

* Vote_Percent=x is it for both voting: for kicking and changing map?
edit. Stupid question I found the answer on soldat.wiki

- Added OnVoteMapStart(Voter: byte; MapName, Reason: string) event (from ChangeLog 1.6.3)

* Error > onvotemapstart not enough parameters. I used this as procedure and as function.
edit. It should look like this: function OnVoteMapStart(Voter: byte; MapName: string): boolean;

* StartVoteMap - It works correctly only every 2 minutes

* Is there a way to off OnVoteMap??
I tried to do function
Code: [Select]
function OnVoteMap(Voter: byte; MapName: string):boolean;
begin
writeconsole(0,'onvotemap',color);
result:=true;
writeconsole(0,'shouldnt add',color);
end;

Doesn't work :((( - messagess are working only.
Title: Re: Change map
Post by: kicikici on April 06, 2014, 11:04:18 am
Code: [Select]
var
   i: integer;

function DisableDefaultVotemap(Player: TActivePlayer; Map: string): Boolean;
begin
   Result:=true;
end;

begin
   for i:=1 to 32 do begin
      Players[i].OnVoteMapStart := @DisableDefaultVotemap;
   end;
end.

This is written in SC3. I cut this from my bigger script but it should work. But ONLY on 1.6.7b1+ version.

* Vote_Percent=x is it for both voting: for kicking and changing map?

Yes.
Title: Re: Change map
Post by: Mighty on April 06, 2014, 11:10:03 am
In short, OnVoteMapStart and OnVoteMap are ScriptCore3 only events.
http://wiki.soldat.pl/index.php/Script_Core_3
Title: Re: Change map
Post by: elMorvano on April 06, 2014, 11:11:48 am
Of course its not only SC3 events. Btw. SC3 has a lot of bugs and it's really not worth to write there YET.

I found a solution with OnVoteMapStart

Okay if you will set result:=true in OnVoteMapStart then voting of map (ESC>change map) doesn't work. This is what I tried to do
Title: Re: Change map
Post by: kicikici on April 23, 2014, 04:17:53 am
Code: [Select]
function OnVoteMapStart(Voter: byte; MapName: string): boolean;
begin
WriteLn('dzialaj kurwo');
Result:=true;
end;

Why OnVoteMapStart event isn't triggered anymore after he had returned true value? I doubt this is expexcted behaviour. I am asking first here, I don't want to do mess on bugtracker unneccesarily.
Title: Re: Change map
Post by: elMorvano on April 23, 2014, 08:24:12 am
Code: [Select]
function OnVoteMapStart(Voter: byte; MapName: string): boolean;
begin
WriteLn('dzialaj kurwo');
Result:=true;
end;

Why OnVoteMapStart event isn't triggered anymore after he had returned true value? I doubt this is expexcted behaviour. I am asking first here, I don't want to do mess on bugtracker unneccesarily.

In soldat every function where result is true won't work :P Try it result:=false then it will works.
Title: Re: Change map
Post by: kicikici on April 23, 2014, 09:56:52 am
I must tell you that you are unaware some event aspects. True value doesn't disable part of script, just doesn't start votemap. Message "dzialaj kurwo" should be always visible, true/false result is irrelevant.

Try this scipt:
Code: [Select]
var
trueorfalse: boolean;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
if Text='!result' then begin
trueorfalse:=not trueorfalse;
WriteConsole(0 , 'trueorfalse:='+iif(trueorfalse=true,'TRUE','FALSE')+';', $FF00FF);
end;
end;

procedure ActivateServer();
begin
trueorfalse:=true;
end;

function OnVoteMapStart(Voter: byte; MapName: string): boolean;
begin
WriteLn('dzialaj kurwo');
Result:=trueorfalse;
end;

-join server
-wait 2 minutes
-use /votemap (check if u got message)
-change result (type !result)
-wait 2 minutes
-use /votemap (check if u got message)
Title: Re: Change map
Post by: kicikici on April 24, 2014, 04:44:10 am
@elMorvano, lack of conclusions?

I found second bug, but to be honest it's an extension of previous one. My first question should be:
Why OnVoteMap event is triggered instead of OnVoteMapStart after OnVoteMapStart had returned true value at first triggering?

Currently this solve all my problems (using OnVoteMap instead of OnVoteMapStart), but this shouldn't work as now.

EDIT:
Bugtracker ticket: http://bugs.soldat.pl/view.php?id=550
Title: Re: Change map
Post by: elMorvano on April 25, 2014, 06:31:23 am
@elMorvano, lack of conclusions?

I found second bug, but to be honest it's an extension of previous one. My first question should be:
Why OnVoteMap event is triggered instead of OnVoteMapStart after OnVoteMapStart had returned true value at first triggering?

Currently this solve all my problems (using OnVoteMap instead of OnVoteMapStart), but this shouldn't work as now.

EDIT:
Bugtracker ticket: http://bugs.soldat.pl/view.php?id=550

Code: [Select]
function OnVoteMapStart(Voter: byte; MapName: string): boolean; // to jest zeby nie dalo sie wlaczyc votowania na mapy ESC>GLosuj na mape
begin
result:=true;
end;

It makes impossible to turn on voting by ESC > change map and by command StartVoteMap('name','reason');

StartVoteMap can open the window with F11|F12 but this won't count as votes.

function OnVoteMap probably is just a procedure which works always when you Click F12. You can not turn off this. I did myself scripts for voting. Both functions are a little bugged :/ Remember StartVoteMap works every 2 minutes (like standard voring)


Title: Re: Change map
Post by: kicikici on April 26, 2014, 05:58:44 am
My main goal was detection if someone want to start vote, EVEN if vote is disabled by using Result:=true;. It is possible but it isn’t so obvious. I will give you answer what I expected from you about my script:
-join server
-wait 2 minutes
(now result:=true;)
-use /votemap – OnVoteMapStart is called (good), OnVoteMap is not called (good), 
-change result (type !result) (now result:=false;)
(but from now value of result in OnVoteMapStart event doesn’t matter)
-wait 2 minutes
-use /votemap – OnVoteMapStart is not called (bad), OnVoteMap is called (bad), 
-wait 2 minutes
-use /votemap – OnVoteMapStart is not called (bad), OnVoteMap is called (bad), 
-wait 2 minutes
-use /votemap – OnVoteMapStart is not called (bad), OnVoteMap is called (bad),
etc.

So it’s possible to detect when vote is starting with using these two events, but it shouldn't work as now.
function OnVoteMap probably is just a procedure which works always when you Click F12.
Not always, only when vote is running, and also when player is active (Player.Team<>5)

BTW
I just noticed that
Code: [Select]
function OnVoteMapStart(Voter: byte; MapName: string): boolean; // to jest zeby nie dalo sie wlaczyc votowania na mapy ESC>GLosuj na mape
begin
result:=true;
end;
disable votekick also. Or maybe I spent too much time on this all and this is caused by something else. Eh...
Title: Re: Change map
Post by: elMorvano on April 26, 2014, 06:54:07 am
function OnVoteMap probably is just a procedure which works always when you Click F12.
Not always, only when vote is running, and also when player is active (Player.Team<>5)
[/quote]

I mean always when you press F12

disable votekick also. Or maybe I spent too much time on this all and this is caused by something else. Eh...

Yeah it disable votekick also :( There i can't even check someone is trying VoteMap or VoteKick
Title: Re: Change map
Post by: kicikici on April 26, 2014, 07:24:47 am
I mean always when you press F12
Always but under some circumstances which I decribed recently.

There i can't even check someone is trying VoteMap or VoteKick
I am not quite sure if you read my last post precisely. You can always detect VoteMap (I didn't check VoteKick so I wont tell anything about this).