Jump to content

Newbie Problem


LabiVila

Recommended Posts

Hello all, I won't post all the script because I think it's not useful,

I've got the button here and:

client-side

yourname = getPlayerName (getLocalPlayer()) 
  
challb = guiCreateButton (0.65, 0.80, 0.30, 0.15, "Challenge", true, PVPw)  
  
function buttonCLICK (button) 
    if (button == "left") then 
    triggerServerEvent ("message", localPlayer, yourname , buttonCLICK) 
    end 
end 
addEventHandler ("onClientGUIClick", challb, buttonCLICK, false))  

how should I do that when I click the challb button, a server-side message appears to everyone in the server saying anything (not important) ? I know it's somehow with triggerServer/ClientEvent but not sure how to use it. I'd be grateful if someone writes the full script.

Link to comment

It would be bad if some writes the full script.

You would copy and paste and come back tomorrow with another question.

In this case I guess you have to trigger a server event that calls a function and in that function you trigger a client event for all clients.

Check the wiki, there are some examples.

Link to comment

Yea managed to solve that one, thanks, by trying myself is better. What about this one?

function playerList () 
    local playerList = guiCreateGridList (0.10, 0.10, 0.50, 0.85, true, PVPw) 
    local column = guiGridListAddColumn (playerList, "Player", 0.85) 
    if (column) then 
            for id, playeritem in ipairs (getElementsByType ("player")) do 
                local row = guiGridListAddRow (playerList) 
                guiGridListSetItemText (playerList, row, column, getPlayerName (playeritem), false, false) 
                end 
        end 
end 
addEventHandler ("onClientResourceStart", getRootElement(), playerList) 

how can I get the clicked player's name and put it to outputChatBox?

https://wiki.multitheftauto.com/wiki/Gu ... etItemText I think it's this but it's honestly hard... I'd be grateful for any help (and any explanation) :)

Link to comment

Yea, it's easy for you :x but not for beginners like me. However, let's not cry,

function playerList () 
    local playerList = guiCreateGridList (0.10, 0.10, 0.50, 0.85, true, PVPw) 
    local column = guiGridListAddColumn (playerList, "Player", 0.85) 
    local asd = guiGridListGetItemText (playerList, column) 
    if (column and asd) then 
            for id, playeritem in ipairs (getElementsByType ("player")) do 
                local row = guiGridListAddRow (playerList) 
                guiGridListSetItemText (playerList, row, column, getPlayerName (playeritem), false, false) 
                outputChatBox (""..asd.."") 
                end 
        end 
end 
addEventHandler ("onClientResourceStart", getRootElement(), playerList) 
  

The code might be confusing but.. I need a hand on it, what isn't working? The debugscript 3 says that it needs a number at line 22, and there's none.

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