-
Posts
21,935 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Castillo
-
addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == fix or source == blow ) then local row, col = guiGridListGetSelectedItem ( Grid ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( Grid, row, 1 ) local player = getPlayerFromNamePart ( playerName ) if ( not player ) then return outputChatBox ( "Invalid player.", 255, 0, 0 ) end triggerServerEvent ( "doVehicleAction", localPlayer, player, ( source == fix and "fix" or source == blow and "blow" ) ) end end end ) function getPlayerFromNamePart ( name ) if ( name ) then for _, player in ipairs ( getElementsByType ( "player" ) ) do local playerName = getPlayerName ( playerName ):gsub ( "#%x%x%x%x%x%x", "" ) if ( playerName:find ( tostring ( name ):lower ( ), 1, true ) ) then return player end end end return false end Try that.
-
That's what I though. Copy the code again and tell me what does it output now.
-
addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == fix or source == blow ) then local row, col = guiGridListGetSelectedItem ( Grid ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( Grid, row, 1 ) outputChatBox ( "Selected player name: ".. playerName ) local player = getPlayerFromNamePart ( playerName ) if ( not player ) then return outputChatBox ( "Invalid player.", 255, 0, 0 ) end triggerServerEvent ( "doVehicleAction", localPlayer, player, ( source == fix and "fix" or source == blow and "blow" ) ) end end end ) function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end Try with that and see what does it output.
-
addCommandHandler setElementDimension
-
That's right TAPL, I guess with the useful function: getPlayerFromNamePart it could work. addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == fix or source == blow ) then local row, col = guiGridListGetSelectedItem ( Grid ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( Grid, row, 1 ) local player = getPlayerFromNamePart ( playerName ) if ( not player ) then return end triggerServerEvent ( "doVehicleAction", localPlayer, player, ( source == fix and "fix" or source == blow and "blow" ) ) end end end ) function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end
-
triggerClientEvent("onTeamMonster", getRootElement(),source) This and every other trigger like this are wrong, you must do it the following way: triggerClientEvent ( source, "onTeamMonster", source ) About the timer, use: setTimer
-
bindKey ( "v", "down", function ( ) setCameraViewMode ( ( getCameraViewMode ( ) == 0 ) and 2 or 0 ) end ) Is that what you wanted?
-
What do you mean by "doesn't work"?
-
My script will only fix/blow the selected player's vehicle, what you are saying is just not possible.
-
I'm not sure why my code didn't work, I use a similar code for my scripts.
-
Columns aren't elements.
-
@TAPL: if eventName == "onClientPlayerJoin" then guiGridListSetItemText(Grid, i, Column, getPlayerName(source):gsub("#%x%x%x%x%x%x", ""), false, false) "i" is not defined anywhere. @manve1: My script should work just fine.
-
-- client side: addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == fix or source == blow ) then local row, col = guiGridListGetSelectedItem ( Grid ) if ( row and col and row ~= -1 and col ~= -1 ) then local playerName = guiGridListGetItemText ( Grid, row, 1 ) local player = getPlayerFromName ( playerName ) if ( not player ) then return end triggerServerEvent ( "doVehicleAction", localPlayer, player, ( source == fix and "fix" or source == blow and "blow" ) ) end end end ) -- server side: addEvent ( "doVehicleAction", true ) addEventHandler ( "doVehicleAction", root, function ( player, action ) local vehicle = getPedOccupiedVehicle ( player ) if ( vehicle ) then if ( action == "fix" ) then fixVehicle ( vehicle ) elseif ( action == "blow" ) then blowVehicle ( vehicle ) end end end )
-
Must be because it was creating column every time, I moved it outside the update function, copy it again.
-
Yeah, I forgot to clear it first, copy my code again.
-
local Column = guiGridListAddColumn ( Grid, "Player", 0.85 ) function playerList ( ) guiGridListClear ( Grid ) if ( Column ) then for _, player in ipairs ( getElementsByType ( "player" ) ) do local Row = guiGridListAddRow ( Grid ) guiGridListSetItemText ( Grid, Row, Column, getPlayerName ( player ):gsub ( "#%x%x%x%x%x%x", "" ), false, false ) end end end addEventHandler ( "onClientResourceStart", resourceRoot, playerList ) addEventHandler ( "onClientPlayerJoin", root, playerList ) addEventHandler ( "onClientPlayerQuit", root, playerList ) addEventHandler ( "onClientPlayerChangeNick", root, playerList ) @Anderl: You could have used: guiGridListClear instead of: for i = 1, #guiGridListGetRowCount(Grid) do guiGridListRemoveRow(Grid, i) end Also, you placed the timer inside the for-loop.
-
He could update it when someone: joins/leaves/changes nick with the following events: onClientPlayerJoin onClientPlayerQuit onClientPlayerChangeNick
-
Si usa la hora del servidor ( server side ), entonces estaran todos igual.
-
Destruya o muera? porque: killPed -- Es para matar a un ped/jugador. destroyElement -- Es para destruir a un elemento.
-
El nametag solo es un color, si vos te referis a los colores HEX, entonces esa funcion no es para obtenerlos.