Author Topic: Automatic Vote Doesnt Work  (Read 2477 times)

0 Members and 4 Guests are viewing this topic.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Automatic Vote Doesnt Work
« on: June 03, 2013, 08:24:43 am »
I saw it on a server, it was working;

Code: [Select]
{'!a2': begin
WriteConsole(0,'Arena2 oylaması baslatmak icin',RGB(0,255,255));
command('/votemap Arena2');
StartVoteMap(ID, 'Arena2')
end;

'!hamsrun': begin
WriteConsole(0,'Hamsrun oylaması baslatmak icin',RGB(0,255,255));
command('/votemap hamsrun');
StartVotemap(ID, 'hamsrun')
end;)

'!lg': begin
WriteConsole(0,'Lagrange oylaması baslatmak icin',RGB(0,255,255));
command('/votemap Lagrange');
StartVoteMap(ID, 'Lagrange')
end;}

What is wrong, players dont see even if they type the command. Nothing on screen.
Is there anybody can write script?
Good, go and play soldat ^^

Offline rOy

  • Soldier
  • **
  • Posts: 120
Re: Automatic Vote Doesnt Work
« Reply #1 on: June 03, 2013, 09:08:52 am »
Code: [Select]
procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
case lowercase(Text) of

'!a2': begin
WriteConsole(0,'Arena2 oylaması baslatmak icin',RGB(0,255,255));
command('/votemap Arena2');
StartVoteMap(ID, 'Arena2')
end;

'!hamsrun': begin
WriteConsole(0,'Hamsrun oylaması baslatmak icin',RGB(0,255,255));
command('/votemap hamsrun');
StartVotemap(ID, 'hamsrun')
end;

'!lg': begin
WriteConsole(0,'Lagrange oylaması baslatmak icin',RGB(0,255,255));
command('/votemap Lagrange');
StartVoteMap(ID, 'Lagrange')
end;
                     end;
                 end;

?
« Last Edit: June 03, 2013, 09:44:49 am by rOy »

DarkCrusade

  • Guest
Re: Automatic Vote Doesnt Work
« Reply #2 on: June 03, 2013, 09:26:28 am »
And please remove the '{' and '}' or the code in between will be simply ignored by the server.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #3 on: June 03, 2013, 09:48:28 am »
They are not working :S
Is there anybody can write script?
Good, go and play soldat ^^

Offline rOy

  • Soldier
  • **
  • Posts: 120
Re: Automatic Vote Doesnt Work
« Reply #4 on: June 03, 2013, 10:23:39 am »
A little note:
After connecting wait 2 minutes ;D

DarkCrusade

  • Guest
Re: Automatic Vote Doesnt Work
« Reply #5 on: June 03, 2013, 10:50:09 am »
(Finally a use for my gettime() function!)

Code: (pascal) [Select]
function gettime(ticks:integer):string;
var minutes,seconds:integer;
begin
 minutes := round(ticks  /  3600);
 seconds := round(ticks mod 3600);
 result  := inttostr(minutes)+' minutes and '+inttostr(seconds)+' seconds';
end;

procedure onplayerspeak(id:byte; text:string);
begin
 if gettickcount() mod 7200 = 0 then
  case lowercase(Text) of

   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap Arena2');
     startvotemap(id,'Arena2')
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap hamsrun');
     startvotemap(id,'hamsrun')
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap Lagrange');
     startvotemap(id,'Lagrange')
    end;
   
  end
 else writeconsole(id,gettime(gettickcount())+' left until you can vote again.',$cc0000);
end;

Please note that players will not be able to vote a map until 2 minutes have passed after a new match started.

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #6 on: June 03, 2013, 12:50:19 pm »
(Finally a use for my gettime() function!)

Code: (pascal) [Select]
function gettime(ticks:integer):string;
var minutes,seconds:integer;
begin
 minutes := round(ticks  /  3600);
 seconds := round(ticks mod 3600);
 result  := inttostr(minutes)+' minutes and '+inttostr(seconds)+' seconds';
end;

procedure onplayerspeak(id:byte; text:string);
begin
 if gettickcount() mod 7200 = 0 then
  case lowercase(Text) of

   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap Arena2');
     startvotemap(id,'Arena2')
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap hamsrun');
     startvotemap(id,'hamsrun')
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',rgb(0,255,255));
     command('/votemap Lagrange');
     startvotemap(id,'Lagrange')
    end;
   
  end
 else writeconsole(id,gettime(gettickcount())+' left until you can vote again.',$cc0000);
end;

Please note that players will not be able to vote a map until 2 minutes have passed after a new match started.

  • ScriptCore v2.4 loaded! Found 5 scripts...

►             
  • Compiling admin fun -> fun.PAS...

►             
  • Compiling default -> Core.pas...

►             
  • Compiling default -> NetworkCore.pas...

►             
  • Compiling default -> AdminCore.pas...

►             
  • Compiling HnS -> hns2.pas...

►             
  • Compiling mapx -> mapc.pas...

►             
  • mapx -> [Error] (20:6): Type mismatch

►            Unable to find variable
► і          Shutting down server...
● і          Disconnected.

They are not working, server doesnt open.
Is there anybody can write script?
Good, go and play soldat ^^

DarkCrusade

  • Guest
Re: Automatic Vote Doesnt Work
« Reply #7 on: June 03, 2013, 01:08:34 pm »
Try the below code. It is 100% working. If it - for whatever the log says - crashes the server, it's because you pasted it to the wrong place. Save the code below in a file of type '.pas' (without the 's) in a new folder in 'SCRIPTS' and create a text file called 'includes'. Write the name and the file extension into this text file. If you call the file containing the code 'core.pas', then you have to write 'core.pas'. If the name of the file containing the code does not show the extension '.pas', that makes no difference. You still write 'core.pas' into the file 'Includes.txt'.

I hope it's working now for you. Else I'll actually have to put all this stuff in a .rar archieve for you and explain how you extract it to the 'SCRIPTS' folder, and I sure would like to do that, but not as much as I would not to do it. ;)

Code: (pascal) [Select]
const
 time_till_vote = 2; // Time until players can vote again (in minutes)

var
 vote_enabled:boolean;

function gettime(ticks:integer):string;
var minutes,seconds:integer;
begin
 minutes := round(ticks  /  3600);
 seconds := round(ticks mod 3600);
 result  := inttostr(minutes)+' minutes and '+inttostr(seconds)+' seconds';
end;

procedure onplayerspeak(id:byte; text:string);
begin
 if vote_enabled then begin
  case lowercase(text) of
   
   '!commands':
     writeconsole(id,'!a2, !hamsrun, !lg',$ffffff);
   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',$00ffff);
     command('/votemap Arena2');
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',$00ffff);
     command('/votemap hamsrun');
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',$00ffff);
     command('/votemap Lagrange');
    end;
   
  end;
 
  vote_enabled := false;
 
 end else writeconsole(id,gettime(gettickcount())+' left until you can vote again.',$cc0000);
end;

procedure apponidle(ticks:integer);
begin
 if ticks mod (3600 * time_till_vote) = 0 then vote_enabled := true;
end;

procedure onmapchange(newmap:string);
begin
 vote_enabled := false;
end;

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #8 on: June 03, 2013, 03:25:54 pm »
Try the below code. It is 100% working. If it - for whatever the log says - crashes the server, it's because you pasted it to the wrong place. Save the code below in a file of type '.pas' (without the 's) in a new folder in 'SCRIPTS' and create a text file called 'includes'. Write the name and the file extension into this text file. If you call the file containing the code 'core.pas', then you have to write 'core.pas'. If the name of the file containing the code does not show the extension '.pas', that makes no difference. You still write 'core.pas' into the file 'Includes.txt'.

I hope it's working now for you. Else I'll actually have to put all this stuff in a .rar archieve for you and explain how you extract it to the 'SCRIPTS' folder, and I sure would like to do that, but not as much as I would not to do it. ;)

Code: (pascal) [Select]
const
 time_till_vote = 2; // Time until players can vote again (in minutes)

var
 vote_enabled:boolean;

function gettime(ticks:integer):string;
var minutes,seconds:integer;
begin
 minutes := round(ticks  /  3600);
 seconds := round(ticks mod 3600);
 result  := inttostr(minutes)+' minutes and '+inttostr(seconds)+' seconds';
end;

procedure onplayerspeak(id:byte; text:string);
begin
 if vote_enabled then begin
  case lowercase(text) of
   
   '!commands':
     writeconsole(id,'!a2, !hamsrun, !lg',$ffffff);
   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',$00ffff);
     command('/votemap Arena2');
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',$00ffff);
     command('/votemap hamsrun');
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',$00ffff);
     command('/votemap Lagrange');
    end;
   
  end;
 
  vote_enabled := false;
 
 end else writeconsole(id,gettime(gettickcount())+' left until you can vote again.',$cc0000);
end;

procedure apponidle(ticks:integer);
begin
 if ticks mod (3600 * time_till_vote) = 0 then vote_enabled := true;
end;

procedure onmapchange(newmap:string);
begin
 vote_enabled := false;
end;

Man thanks a lot it is working but first sorry; I dont want time array, there is 18 minutes and 2375.. 2400 seconds left, if I type !a2 or another command, I dont want big time and I want normal vote, you know that vote, press ESC votemap and select the map and choose, like that, I want it too, if I type !a2 it will automatically open vote as normal manuel vote. Time likes it too (again per 2 minutes) And my laptop's time crashed, my laptop's battery isnt working correct, I always use adapter and my BIOS battery died :D I hadnt changed it, still I'm using wrong clock, I think so; the time when I type !a2 never correct, I typed !a2 first, 18 minutes 925 seconds was on the screen, I type again, 18 minutes 2375 seconds was on the screen :D It must normal vote.
Is there anybody can write script?
Good, go and play soldat ^^

DarkCrusade

  • Guest
Re: Automatic Vote Doesnt Work
« Reply #9 on: June 03, 2013, 04:43:18 pm »
Delete everything in the .pas file and copy the below code into the now empty file. Compiled and will work to a 100%

Code: (pascal) [Select]
procedure onplayerspeak(id:byte; text:string);
begin
  case lowercase(text) of
   
   '!commands':
     writeconsole(id,'!a2, !hamsrun, !lg',$ffffff);
   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',$00ffff);
     command('/votemap Arena2');
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',$00ffff);
     command('/votemap hamsrun');
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',$00ffff);
     command('/votemap Lagrange');
    end;
   
  end;
 
end;

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #10 on: June 03, 2013, 05:22:59 pm »
Man man man :) Sorry for all but it needed another command, if you type !a2; you will see what should you do for vote, but I want that if you type !a2, automatically open vote not needed + /votemap ...
Sorry but I cant do it :/

EDIT: Man, I try that "procedure startvotemap" and if player type !arena2 or !hamsrun or !lagrange, automatically starts vote. Not needed /votemap arena2. Only !arena2 must open vote for arena2. It is what I want :/ As toyux's script, if you type !vote, arena2 vote starts.
« Last Edit: June 03, 2013, 07:07:13 pm by MrHamsTR »
Is there anybody can write script?
Good, go and play soldat ^^

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: Automatic Vote Doesnt Work
« Reply #11 on: June 07, 2013, 08:36:01 am »
Man man man :) Sorry for all but it needed another command, if you type !a2; you will see what should you do for vote, but I want that if you type !a2, automatically open vote not needed + /votemap ...
Sorry but I cant do it :/

EDIT: Man, I try that "procedure startvotemap" and if player type !arena2 or !hamsrun or !lagrange, automatically starts vote. Not needed /votemap arena2. Only !arena2 must open vote for arena2. It is what I want :/ As toyux's script, if you type !vote, arena2 vote starts.

Just procedure for voting
« Last Edit: June 07, 2013, 08:57:42 am by skrX »

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #12 on: June 07, 2013, 08:49:49 am »
 ScriptCore v2.4 loaded! Found 7 scripts...
 Compiling admin fun -> fun.PAS...
Compiling default -> Core.pas...
Compiling default -> NetworkCore.pas...
Compiling default -> AdminCore.pas...
Compiling HnS -> hns2.pas...
 Compiling mapc -> mapc.pas...           
 mapc -> [Error] (4:1): Duplicate identifier 'MAXPLAYERS'
 Unable to find variable
Shutting down server...
 Disconnected.
Is there anybody can write script?
Good, go and play soldat ^^

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: Automatic Vote Doesnt Work
« Reply #13 on: June 07, 2013, 08:54:49 am »
I needed to test...

Code: [Select]
const
//max players
MAXPLAYER = 32;

//vote config
Percent = 75;
InitTime = 30; // a starting time of voting for the next map
AddTime = 8; 

var
Voted: array[1..MAXPLAYER] of boolean;
Time: integer;

procedure OnPlayerSpeak(ID: byte; Text: string);
var i,Total: integer;
begin

if (LowerCase(Text) = '!arena2') or (LowerCase(Text) = '!a2')  then
begin
if Voted[ID] then WriteConsole(ID, 'You have already voted!',rgb(255,0,0))
else if (Time = 0) then Time := InitTime
else Time := Time + Addtime;
Voted[ID] := true;
for i := 1 to MAXPLAYER do if (GetPlayerStat(i, 'Active') = true) and (Voted[i]) then Total := Total + 1;
if ((100 * Total) / NumPlayers >= Percent) then begin
for i := 1 to MAXPLAYER do Voted[ID] := false;
WriteConsole(0, 'Nextmap vote passed.', rgb(255,255,255));
Command('/map Arena2');
end else
WriteConsole(0,FloattoStr(RoundTo(100 * Total / NumPlayers, 1))+ '% / '+ InttoStr(Percent) + '%', rgb(255,255,255));
end;
end;

« Last Edit: June 07, 2013, 04:20:34 pm by skrX »

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #14 on: June 07, 2013, 09:00:13 am »
Man, you dont understand, I want open normal vote like press esc menu with !a2, no vote with %, if you type !a2, normal vote must open. Last edit is working;

Delete everything in the .pas file and copy the below code into the now empty file. Compiled and will work to a 100%

Code: (pascal) [Select]
procedure onplayerspeak(id:byte; text:string);
begin
  case lowercase(text) of
   
   '!commands':
     writeconsole(id,'!a2, !hamsrun, !lg',$ffffff);
   '!a2':
    begin
     writeconsole(0,'Arena2 oylaması baslatmak icin',$00ffff);
     command('/votemap Arena2');
     end;
  '!hamsrun':
    begin
     writeconsole(0,'Hamsrun oylaması baslatmak icin',$00ffff);
     command('/votemap hamsrun');
    end;
  '!lg':
    begin
     writeconsole(0,'Lagrange oylaması baslatmak icin',$00ffff);
     command('/votemap Lagrange');
    end;
   
  end;
 
end;

But it is working with /votemap arena2, I want !arena2 only, okay?
Is there anybody can write script?
Good, go and play soldat ^^

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: Automatic Vote Doesnt Work
« Reply #15 on: June 07, 2013, 04:11:59 pm »
Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
var
    Mapname, Reason: string;
begin
if (Text = '!arena2') then
begin
        if FileExists('maps/Arena2.pms') or FileExists('maps/Arena2.PMS') then
begin
           StartVoteMap('Arena2', ' Vote');
        end;
    end;
end;
« Last Edit: June 07, 2013, 04:14:08 pm by skrX »

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Automatic Vote Doesnt Work
« Reply #16 on: June 07, 2013, 10:53:19 pm »
Man, you dont understand, I want open normal vote like press esc menu with !a2, no vote with %, if you type !a2, normal vote must open. Last edit is working;

...

But it is working with /votemap arena2, I want !arena2 only, okay?

So you are saying you want to disable the /votemap command?
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #17 on: June 08, 2013, 05:24:21 am »
disable and change it to !arena2

EDIT: skrx man <3 it is working! thanks but I want add 2 more maps, lagrange and hamsrun? how can I add them?
EDIT2: skrx, it is working vote works but map isnt changing :S why? I joined server then typed !arena2 and vote opened but map doesnt change :( and my name doesnt seem in vote, vote=server arena2????
EDIT3: it is working with all map is changing but there is a problem (I guess). if you are alone in server and type !arena2, server seem who opened the vote and map doesnt change (if you are alone in server) but if there is/are 2-3 players more and if you put f12 (accept server's vote) 1 more vote comes again with name who accept the vote, if there are 3 players (with you) and everybody put f12, you must put f12 3 times (first server's vote, 2. who put f12 and 3. who put f12)

WHY?
« Last Edit: June 08, 2013, 05:51:16 am by MrHamsTR »
Is there anybody can write script?
Good, go and play soldat ^^

Offline skrX

  • Soldier
  • **
  • Posts: 112
  • x ye.
Re: Automatic Vote Doesnt Work
« Reply #18 on: June 08, 2013, 07:35:29 am »
I think it's a bug.
« Last Edit: June 08, 2013, 07:45:48 am by skrX »

Offline MrHamsTR

  • Soldier
  • **
  • Posts: 209
  • One day, everything will end..
Re: Automatic Vote Doesnt Work
« Reply #19 on: June 08, 2013, 07:43:37 am »
Ohh it's ok, I looked it in other servers, it's like mine, thx man it's working :)
Is there anybody can write script?
Good, go and play soldat ^^