manve1 Posted November 12, 2012 Posted November 12, 2012 I made a script ( it might make no sense ) and i can't figure out that when i click on the grid and on my or my mates name, serial stay's the same, could you possibly fix it? addEventHandler( 'onClientGUIClick', aGrid, function() local pRow = guiGridListGetSelectedItem( aGrid ) if (pRow and pRow ~= -1) then guiSetText ( aSerial, "Serial: " .. getPlayerSerial( localPlayer, pRow, 1 ) ) end end ) Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 12, 2012 Posted November 12, 2012 getPlayerSerial() client-side only returns the client's serial, not the one's you want to know. However, guiSetText() doesn't work for grids as far as I know, you must use guiGridListSetItemText(). Use the code below, haven't tested it and I assume you have a player column in your gridlist and it is the first column? If yes, then it should work, if not, then change the columns in the below script. Client-side addEvent("onClientPlayerSerialFetched", true) addEventHandler("onClientPlayerSerialFetched", root, function(serial, row) guiGridListSetItemText(aGrid, row, 1, "Serial: " .. serial, false, false) end ) addEventHandler("onClientGUIClick", aGrid, function() local pRow = guiGridListGetSelectedItem(aGrid) if (pRow and pRow ~= -1) then triggerServerEvent("onClientPlayerSerialRequested", localPlayer, guiGridListGetItemText(aGrid, pRow, 1), pRow) end end ) Server-side addEvent("onClientPlayerSerialRequested", true) addEventHandler("onClientPlayerSerialRequested", root, function(player, row) if player and getPlayerFromName(player) then triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(player)), row) else outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) end end ) If I helped you, please click the like button on the right Thanks!
manve1 Posted November 12, 2012 Author Posted November 12, 2012 Yeh, it worked, but i didn't want it on the grid, oh well, i fixed it, but when i click on someone else not me, it returns false Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 12, 2012 Posted November 12, 2012 It's very weird then. It should return their serial if the player is found with the exact name listed in the gridlist. If gridlist removes hex codes and the player uses hex codes anyway, it will mess up. I can give you a findPlayer function soon for no need for such exact matches. If I helped you, please click the like button on the right Thanks!
manve1 Posted November 13, 2012 Author Posted November 13, 2012 NO no, u don't understand me, i already get player names on the grid list, when i click on their names, i want a label to get changed to their serial e.g. "Serial: blahblah ...." Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 13, 2012 Posted November 13, 2012 Use guiSetText to change the string value of a label. If I helped you, please click the like button on the right Thanks!
manve1 Posted November 17, 2012 Author Posted November 17, 2012 When i click on someone else, i get "DEBUG: 'onClientPlayerSerialRequested' returned false." in my chat D: is it possible to fix it? Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 17, 2012 Posted November 17, 2012 When i click on someone else, i get "DEBUG: 'onClientPlayerSerialRequested' returned false." in my chat D: is it possible to fix it? This means the player was not found. If I helped you, please click the like button on the right Thanks!
manve1 Posted November 17, 2012 Author Posted November 17, 2012 Lol? how can't it be found if he is playing D: Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 17, 2012 Posted November 17, 2012 Lol? how can't it be found if he is playing D: Probably because the gridlist doesn't show his hex color codes if he has any and they have been removed by your script. Also if the gridlist shows partial names, it won't find the player. You can try the following code: Server-side function findPlayer(name, player) if name == "*" and getElementType(player) == "player" then return player else local matches = {} for i,v in ipairs(getElementsByType("player")) do if getPlayerName(v) == name and isLogged(v) then return v end local playerName = getPlayerName(v):gsub("#%x%x%x%x%x%x", "") playerName = playerName:lower() if playerName:find(name:lower(), 0) and isLogged(v) then table.insert(matches, v) end end if #matches == 1 then return matches[1] end return false end end addEvent("onClientPlayerSerialRequested", true) addEventHandler("onClientPlayerSerialRequested", root, function(player, row) local target = findPlayer(player, source) if target then triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(target)), row) else outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) end end ) If I helped you, please click the like button on the right Thanks!
manve1 Posted November 17, 2012 Author Posted November 17, 2012 I get this error now ERROR: server.lua:15: attempt to call global 'isLogged' (a nil value) Looking for tutorials or information? check out: www.simpleask.co.uk
Castillo Posted November 17, 2012 Posted November 17, 2012 Means you don't have the function: "isLogged" defined anywhere. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manve1 Posted November 17, 2012 Author Posted November 17, 2012 So how could i fix this? Looking for tutorials or information? check out: www.simpleask.co.uk
Castillo Posted November 17, 2012 Posted November 17, 2012 Why are you using a function that does not exist? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manve1 Posted November 17, 2012 Author Posted November 17, 2012 I asked help, and myonlake gave me code with it Looking for tutorials or information? check out: www.simpleask.co.uk
Castillo Posted November 17, 2012 Posted November 17, 2012 function findPlayer(name, player) if name == "*" and getElementType(player) == "player" then return player else local matches = {} for i,v in ipairs(getElementsByType("player")) do if getPlayerName(v) == name and not isGuestAccount ( getPlayerAccount ( v ) ) then return v end local playerName = getPlayerName(v):gsub("#%x%x%x%x%x%x", "") playerName = playerName:lower() if playerName:find(name:lower(), 0) and not isGuestAccount ( getPlayerAccount ( v ) ) then table.insert(matches, v) end end if #matches == 1 then return matches[1] end return false end end addEvent("onClientPlayerSerialRequested", true) addEventHandler("onClientPlayerSerialRequested", root, function(player, row) local target = findPlayer(player, source) if target then triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(target)), row) else outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manve1 Posted November 17, 2012 Author Posted November 17, 2012 returned false D: Looking for tutorials or information? check out: www.simpleask.co.uk
Castillo Posted November 17, 2012 Posted November 17, 2012 What returns false? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manve1 Posted November 17, 2012 Author Posted November 17, 2012 It output a message that: "DEBUG: 'onClientPlayerSerialRequested' returned false." And when i login, it doesn't change the labels Looking for tutorials or information? check out: www.simpleask.co.uk
Castillo Posted November 17, 2012 Posted November 17, 2012 Meaning findPlayer did not found that player. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
manve1 Posted November 17, 2012 Author Posted November 17, 2012 So aparently you saying it didn't find me? Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 17, 2012 Posted November 17, 2012 Why are you using a function that does not exist? Forgot to remove it, I use it in my scripts and I added that to make sure the player is logged in. So aparently you saying it didn't find me? Does your gridlist have the names of the players on it? Also, are you logged in? If I helped you, please click the like button on the right Thanks!
manve1 Posted November 17, 2012 Author Posted November 17, 2012 Im loged in ... Yes gridlist does .. Looking for tutorials or information? check out: www.simpleask.co.uk
myonlake Posted November 17, 2012 Posted November 17, 2012 Is the playername listed on the first column? If I helped you, please click the like button on the right Thanks!
manve1 Posted November 17, 2012 Author Posted November 17, 2012 Everything works, just it doesn't change the label .... Looking for tutorials or information? check out: www.simpleask.co.uk
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now