Jump to content

Reserved Slot


.:HyPeX:.

Recommended Posts

Posted

Just came out with the idea, we got a 32 Slot server on our clan, is there a function to get player count? (i know i could count them with like a joinquit and a table or local) but i'm asking if there is a function to get current player count in the server. This is to let only 31 players join and reserve a slot for the members (via getPlayerName on join).

Thanks

HyPeX

Posted

Found this problem..

i want to find the lastest player who joined who hasnt got the LxG in its name(to avoid kicking LxG players)

How could i do the opposite into a table? like this?

  
local LastLogued = table.gmatch(Players, ~LxG) 
  

Posted

I've been working alot since this.. this is my end script.. (not sure if it will work the actual search of the name i asked on the previous post.. but if it does)

  
----Reservation-Script-by-HyPeX-- 
  
----Locals---- 
local Players = {} 
local g_PlayerCount = getPlayerCount() 
local LastLogued = table.gmatch(Players, ~LxG) 
local TablePos = getElementData( source, TablePosition ) 
local accPlayer = getPlayerAccount( source ) 
------------------------------- 
  
----Messages of Startup---- 
outputChatBox ("#00aaff[Reservation]: 32nd Slot is Now reserved for LxG Members!",root,  255, 255, 255, true) 
  
------------------------------- 
  
----Functions--- 
antiFake = {} 
function credits(onPlayerJoin) 
local Name = getPlayerName(source) 
setElementData( accPlayer, TablePosition, math.random( 99999 )) 
table.insert(Players, TablePos, Name) 
    if g_PlayerCount == 31 then 
        if string.match(Name, LxG) = LxG then 
        outputChatBox( "Welcome LxG Player, You are joining in a reserved Slot", source, 55, 125, 255 ) 
        antiFake[source] = setTimer(function(source) antiFake[source] = nil end, 1000*60*2, 1, source) 
            if string.match(LastLogued, LxG) 
            then kickPlayer (LastLogued, Reservation, you were kicked becouse you were the lastest player who joined, sorry ) 
        else 
        kickPlayer(source, Reservation, This slot is reserved for a LxG Member, we're sorry) 
    end 
    else 
    outputChatBox ( "Reserved Slot for LxG Members Script Online", source, 55, 125, 255 ) 
end 
end 
addEventHandler("onPlayerJoin", root, credits) 
  
function antiFakeLogin() 
Player = getPlayerFromName( source ) 
if isTimer(antiFake[source]) then 
outputchatbox ( "[Reservation]:"..Player.."was kicked for trying to fake the reserved slot!", 0, 175 ,255 ) 
kickPlayer( source, Reservation, Dont fake the reservation slot! )  
end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), antiFakeLogin) 
  
addEventHandler ( "onResourceStop", resourceRoot, 
table.remove( Players, TablePos ) 
removeElementData( source, TablePosition ) 
addEventHandler ( "onPlayerQuit", root, onDeleteTables ) 
 

Posted
you need to put messages in a string. Otherwise, the server will be looking for an invalid variable.

how?

this should be the totally fixed end (without saying that)

  
----Reservation-Script-by-HyPeX-- 
  
----Locals---- 
local Players = {} 
local g_PlayerCount = getPlayerCount() 
local LastLogued = table.match(Players, ~=LxG, 99999) 
local TablePos = getElementData( source, TablePosition ) 
local accPlayer = getPlayerAccount( source ) 
local Name = getPlayerName(source) 
------------------------------- 
  
----Messages of Startup---- 
outputChatBox ("#00aaff[Reservation]: 32nd Slot is Now reserved for LxG Members!",root,  255, 255, 255, true) 
  
------------------------------- 
  
----Functions--- 
antiFake = {} 
function credits(onPlayerJoin) 
setElementData( accPlayer, TablePosition, math.random( 99999 )) 
table.insert(Players, TablePos, Name) 
    if g_PlayerCount == 2 then 
        if string.match(Name, LxG) = LxG then 
        outputChatBox( "Welcome LxG Player, You are joining in a reserved Slot", source, 55, 125, 255 ) 
        antiFake[source] = setTimer(function(source) antiFake[source] = nil end, 1000*60*2, 1, source) 
        kickPlayer(LastLogued, Reservation, you were kicked becouse you were the lastest player who joined. sorry ) 
        else 
        kickPlayer(source, Reservation, this slot is reserved for LxG Members. sorry ) 
    end 
    else 
    outputChatBox ( "Reserved Slot for LxG Members Script Online", source, 55, 125, 255 ) 
end 
end 
addEventHandler("onPlayerJoin", root, credits) 
  
function antiFakeLogin() 
Player = getPlayerFromName( source ) 
if isTimer(antiFake[source]) then 
outputchatbox ( "[Reservation]:"..Player.."was kicked for trying to fake the reserved slot!", 0, 175 ,255 ) 
kickPlayer( source, Reservation, Dont fake the reservation slot! )  
end 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), antiFakeLogin) 
  
function ClearPlayerLeaving 
table.remove( Players, TablePos ) 
removeElementData( accPlayer, TablePosition ) 
end 
addEventHandler ( "onPlayerQuit", resourceRoot, ClearPlayerLeaving ) 

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...