Hi,
This script will do just what you guys are asking for
I can't upload attachments so, here it is the code:
First, create a folder named "votegmonjoin" in "...\MTA San Andreas\server\mods\deathmatch\resources\"
Now, create a file named "votegmonjoin_server.lua" inside the folder you created before. Copy and paste the code bellow to this file:
function vgmGameModeRunning()
outputDebugString("<DEBUG>(Server): vgmGameModeRunning() called!")
local resource = call ( getResourceFromName("mapmanager"), "getRunningGamemode" )
if ( resource == nil ) then
--TODO: Its this check always valid?
-- gamemode is not running = Start vote!
executeCommandHandler ( "votemode", source )
return false
end
return true
end
addEventHandler("onPlayerJoin", getRootElement(), vgmGameModeRunning)
Create another file named "meta.xml" inside the folder you created before. Copy and paste the code bellow to this file:
<meta>
<info author="impression" description="Execute /votemode on player join if no game modes are running." type="script" version="0.1" />
<include resource="mapmanager" />
<include resource="votemanager" />
<script src="votegmonjoin_server.lua" type="server"/>
</meta>
Now, whe need to give permission to this script to execute the function "executeCommandHandler ()".
Open the ACL file (acl.xml) located in " "...\MTA San Andreas\server\mods\deathmatch\" and, add the following code at top of file after the tag "":
<group name="VoteGmOnJoin">
<acl name="VoteGmOnJoin"/>
<object name="resource.votegmonjoin"/>
</group>
Scroll down to the bottom of the file and add the following code before the last "":
<acl name="VoteGmOnJoin">
<right name="function.executeCommandHandler" access="true"/>
</acl>
Start the script and you are set. Now, when a player joins the server, and no gamemode is being executed, he will automatically execute the "/votemode" command from the "votemanager" script.
Have fun.
EDIT: Fixed a typo in the "meta.xml" file code.