Jump to content

/votemode on join


SanZoR

Recommended Posts

I never made something in lua but i tried.

It doesn't give an error, nor does it work, but here ya go :D

function startVote( ) 
     local mode = getGameType () 
     local joinedPlayerName = getClientName ( source ) 
     if( mode == nil ) then 
     executeCommandHandler ( "votemode", source ) 
    end 
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(), startVote ) 
  

dont laugh :P

Edited by Guest
Link to comment

Hi,

This script will do just what you guys are asking for :wink:

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.

Link to comment
Hi,

This script will do just what you guys are asking for :wink:

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.

Nice job!

This is what i was looking for :wink:

Thank you very much!

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...