DazzaJay Posted December 13, 2008 Share Posted December 13, 2008 Ive searched around, and only found a thread of somone else trying to do the same thing, but that didnt work properly. https://forum.multitheftauto.com/viewtop ... de#p268362 Basically, im looking for a script that works like this: On player join, Check to see if a Game mode is running. If No game mode is running, then start a VoteMode. If a mode is running, Do nothing. Im sure more than just me are looking for a script like this. Link to comment
Mr.Hankey Posted December 13, 2008 Share Posted December 13, 2008 Such a script might really come in handy. Here's what I got so far (untested) mm = getResourceFromName ("mapmanager") --vm = getResourceFromName ("votemanager") function join () --on player join if getPlayerCount() == 1 then --check if he's the only player if call (mm, "getRunningGamemode") == false then --if no gamemode is running --call (vm, "voteBetweenModes", --no idea how to use that properly executeCommandHandler ("votemode", source) --start a gamemode poll elseif call (mm, "getRunningGamemodeMap") == false then --elseif no map is running executeCommandHandler ("votemap", source, call (mm, "getRunningGamemode")) --start a map poll for the running gamemode else --else call (mm, "changeGameModeMap", call (mm, "getRunningGamemodeMap")) --restart the currently running map end end end addEventHandler ("onPlayerJoin", getRootElement(), join) It still uses the not so nice executeCommandHandler way but there is no appropriate votemode function exported by the votemanager resource and "voteBetweenModes" is hard to use as I couldn't figure out a way to pass all gamemode pointers as arguments for that function. Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 Would you mind if i add it into the VotemanagerV2 Resource? : https://community.multitheftauto.com/index.html?p ... ils&id=214 (Credit would be given to you for this part ofcourse) Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 Cool, iil give it a test run in my test server, and if all is good, iil add it into VotemanagerV2 and roll out another ver. Link to comment
Mr.Hankey Posted December 13, 2008 Share Posted December 13, 2008 Another solution now using exported votemanager functions instead of executeCommandHandler: mm = getResourceFromName ("mapmanager") vm = getResourceFromName ("votemanager") function join () --on player join if getPlayerCount() == 1 then --check if he's the only player if call (mm, "getRunningGamemode") == false then --if no gamemode is running local gamemodes = call (mm, "getGamemodes") call (vm, "voteBetweenModes", unpack(gamemodes)) --executeCommandHandler ("votemode", source) --start a gamemode poll elseif call (mm, "getRunningGamemodeMap") == false then --elseif no map is running --executeCommandHandler ("votemap", source, call (mm, "getRunningGamemode")) --start a map poll for the running gamemode local maps = call (mm, "getMapsCompatibleWithGamemode", call (mm, "getRunningGamemode")) call (vm, "voteBetweenMaps", unpack (maps)) else --else call (mm, "changeGameModeMap", call (mm, "getRunningGamemodeMap")) --restart the currently running map end end end addEventHandler ("onPlayerJoin", getRootElement(), join) Again, this is untested as im too lazy to setup a new resource Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 The first one didnt work, i didnt see any errors or anything, iil check that new one in a sec. But, How would i go about Exporting a Votemode function? is it as simple as adding to the Meta? or is there other stuff that would be needed? :::EDIT::: That one responds the same. i do see an error : "ERROR: call: Check the function exists, its exported and you've passed the correct arguments" Which could be anything. Link to comment
Mr.Hankey Posted December 13, 2008 Share Posted December 13, 2008 getRunningGamemode will never return false that's the problem I modified the if checks a bit and fixed a typo that caused the error. So now there is actually the possibility that the script reaches the point where to start a vote^^ mm = getResourceFromName ("mapmanager") vm = getResourceFromName ("votemanager") function join () --on player join if getPlayerCount() == 1 then --check if he's the only player if call(mm, "isGamemode", call (mm, "getRunningGamemode")) == false then --if no gamemode is running local gamemodes = call (mm, "getGamemodes") call (vm, "voteBetweenModes", unpack(gamemodes)) --executeCommandHandler ("votemode", source) --start a gamemode poll elseif call(mm, "isMap", call (mm, "getRunningGamemodeMap")) == false then --elseif no map is running --executeCommandHandler ("votemap", source, call (mm, "getRunningGamemode")) --start a map poll for the running gamemode local maps = call (mm, "getMapsCompatibleWithGamemode", call (mm, "getRunningGamemode")) call (vm, "voteBetweenMaps", unpack (maps)) else --else call (mm, "changeGamemodeMap", call (mm, "getRunningGamemodeMap")) --restart the currently running map end end end addEventHandler ("onPlayerJoin", getRootElement(), join) Link to comment
Gamesnert Posted December 13, 2008 Share Posted December 13, 2008 getRunningGamemode will never return false that's the problem It either returns the gamemode or nil, as far as I could see in the script. Maybe that would be a solution, replacing false with nil? Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 I tested again, No errors, nothing, no mode vote. I have attached a link, to show how i have incorperated it into Votemanager V2 its got its own LUA file "modestarter.lua" as it could be how im incorporating it in with VMV2 http://public.potholestudios.com/other/votemanager.zip iima get some sleep, iil be back in about 12 hours Link to comment
Mr.Hankey Posted December 13, 2008 Share Posted December 13, 2008 Attached a new (working) version. Now the modestarter part works perfect but somehow after a vote is finished the poll display is not destroyed but i'm not sure if that's a bug related to my script... Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 iil check into it, as i know that after a vote finishess, Race Mode often starts another one on its own (Cos its retarded) Yeah, thats a bug ive never seen before. also, can it be put on a timer, so it starts a mode vote 5 seconds after the player joins? instead of on the spot, as it often starts the vote before the client can recoeve the votemanager, so, it dosent appear, then, reconnects result in lots of "You must wait 300 seconds before starting another vote" Link to comment
DazzaJay Posted December 13, 2008 Author Share Posted December 13, 2008 This bug is really really strange, and i cant for the life of me work it out. I see that you use the folllowing to start the mode vote. executeCommandHandler ("votemode", source) So im guessing it acts the same as if i just typed /votemode into the chat Diffrerence is, when i type /votemode it dosent get stuck. heres a stupid idea, (but worth a shot) i know i can type /votemode into console, and "Console" will start a vote. How would i change that command handler so the vote gets started by console? Would it be as simple as changing it to executeCommandHandler ("votemode", console) ? :::EDIT::: I think i may have found the issue. This error only happens when the modestarter script starts a mode vote. votemanager_client.lua: addEventHandler: onClientRender is already handled - line: 222 But i dont see how. this is line 222: addEventHandler("onClientRender", rootElement, updateTime) Either way, i still have a hunch that if it thaught "Console" was starting the vote, and not the player, it might work fine. Link to comment
50p Posted December 14, 2008 Share Posted December 14, 2008 AFAIR votemanager has a function for starting polls. EDIT: https://wiki.multitheftauto.com/index.ph ... otemanager Link to comment
DazzaJay Posted December 14, 2008 Author Share Posted December 14, 2008 That looks like the Standard Votemanager resource you linked to. Which is completley pointless. Concidering im trying to make an Automatic Votemode function if a player joins and no mode is runing, and intergrate it with a FIXED version of that votetemanager. Which, has all the same functions of that. Link to comment
Mr.Hankey Posted December 14, 2008 Share Posted December 14, 2008 50p I know and I already tried using them (see 3rd or 4th post) but I couldn't really figure out to make it work. This executeCommandHandler solution was just a quick workaround. You can get the Console Element by using getElementByIndex ("console", 0) Link to comment
50p Posted December 14, 2008 Share Posted December 14, 2008 call() doesn't seem to work now or it didn't in r35 (which I'm using). Link to comment
DazzaJay Posted December 14, 2008 Author Share Posted December 14, 2008 You can get the Console Element by using getElementByIndex ("console", 0) So i would change the line to this right? executeCommandHandler ("votemode", getElementByIndex ("console", 0)) Link to comment
50p Posted December 15, 2008 Share Posted December 15, 2008 Does executeCommandHandler works? It didn't in DP2.x because if it did, many servers would have a script that changes chatbox to look better by executing commands. Link to comment
DazzaJay Posted December 15, 2008 Author Share Posted December 15, 2008 yeah, executeCommandHandler works, well, on this ServerSide script. not sure if it works Client Side. Link to comment
Mr.Hankey Posted December 15, 2008 Share Posted December 15, 2008 executeCommandHandler always worked in dp2.x but afaik it does not work with hardcoded commands such as chatfont, reconnect etc. Though some of the hardcoded commands are accessable by using toggleControl and passing them as the control name Link to comment
eXo|Flobu Posted December 15, 2008 Share Posted December 15, 2008 this is a working modestarter.lua without executeCommandHandler Link to comment
DazzaJay Posted December 16, 2008 Author Share Posted December 16, 2008 thanks guys, i just made some slight adjustments, as i thaught "if more than one person joins at same time, say 2 people on a LAN, it would recognise more than one player and not start the vote" so i set it to If theres less than 5 players, and no mode running, then start the mode vote. i also added a timer that checks every so often if there is no modes running, and starts a mode vote. (just incase a moron joins and votes "Cancel Vote") (I have seen a lot of morons vote 9, then bitch about "i cant spawn" so it should kep poping up till a mode is started. i will edit with link soon. :::EDIT::: https://community.multitheftauto.com/index.html?p ... anddescr=1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now