Jump to content

Problem with "triggerServerEvent"


xF_Micka

Recommended Posts

Hello.

I have a problem on my server, without aftermath but an error always appears in my server logs.

When a player joins, he gets this error on chat : say: Invalid text length

In server logs :

[2014-01-28 17:53:47] ERROR: Client triggered serverside event onRequestMapName, but event is not added serverside

In my race gamemode :

addEventHandler("onClientResourceStart", g_ResRoot,  
    function() 
        yo = dxGetFontHeight(c_FontScale, c_Font) 
        triggerServerEvent("onRequestMapName", g_ResRoot) 
    end 
) 

So what's problem with this function "triggerServerEvent" and "OnRequestMapName" ?

Thanks.

Edited by Guest
Link to comment

Sorry but I'm not very experimented in script.

So I try to learn too.

What is the "server side" ?

The part of the code is from a file "info_map" who display elementary informations about the map (name, author, moden, etc.) when she is launched

Here are the full script :

local SCREEN_WIDTH, SCREEN_HEIGHT = guiGetScreenSize() 
  
local name, author, lastTimePlayed, spawnPointCount, playedCount, modename 
local startTick 
  
local enabled = true 
  
local month = {"January","February","March","April","May","June","Juli","August","September","October","November","December"} 
  
function timestampToDate(stamp) 
    local time = getRealTime(stamp) 
    return string.format("%d %s - %02d:%02d",time.monthday,month[time.month+1],time.hour,time.minute) 
end 
  
function handleMapInfo(mapInfo) 
    name            = mapInfo.name or "Unknown" 
    author          = mapInfo.author or "Unknown" 
    playedCount     = tostring(mapInfo.playedCount or "N/A") 
    lastTimePlayed  = timestampToDate(mapInfo.lastTimePlayed) or "Unknown" 
    modename = "" 
        if string.find(name,"%[DM]") then 
            modename = "#FF8C00Deathmatch" 
        elseif string.find(name,"%[DD]") then 
            modename = "#00FFFFDestruction Derby" 
        elseif string.find(name,"%[FUN]") then 
            modename = "#FF0000Shooter" 
        end 
  
outputChatBox("#FFFFFF* #E1AA5AMap created by: #FFFFFF"..author.."",255,255,255,true) 
outputChatBox("#FFFFFF* #E1AA5AMode: #FFFFFF"..modename.."",255,255,255,true) 
outputChatBox("#FFFFFF* #E1AA5APlayed: #FFFFFF"..playedCount.." #E1AA5Atimes",255,255,255,true)  
outputChatBox("#FFFFFF* #E1AA5ALast time: #ffffff"..lastTimePlayed.."",255,255,255,true) 
  
    startTick = getTickCount() 
     
    if not enabled then 
        addEventHandler("onClientRender",getRootElement(),handleOnRender) 
        enabled = true 
    end 
end 
addEvent("onClientMapStarting",true) 
addEventHandler("onClientMapStarting",getRootElement(),handleMapInfo) 
  
  
local g_Root = getRootElement() 
local g_ResRoot = getResourceRootElement(getThisResource()) 
local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
  
local c_Font = "pricedown" 
local c_FontScale =0.90 
local yo 
  
local mapName 
  
addEvent("onSendMapName", true) 
addEventHandler("onSendMapName", g_ResRoot, 
    function(name) 
        mapName = name 
    end 
) 
  
addEventHandler("onClientResourceStart", g_ResRoot,  
    function() 
        yo = dxGetFontHeight(c_FontScale, c_Font) 
        triggerServerEvent("onRequestMapName", g_ResRoot) 
    end 
) 
  
addEventHandler("onClientRender", g_Root,  
    function() 
        if mapName then 
            dxDrawText("Current Map: '" .. mapName .."'", 5, screenHeight-yo-2, screenWidth, screenHeight, tocolor(0, 255, 0, 255), c_FontScale, c_Font) 
        end 
    end 
) 

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