#meS Posted September 7, 2015 Share Posted September 7, 2015 hello i made gui message but not working.. debug:attempt to concatenat local 'choosedPlayer' (a nil value) code: client msgGRID = guiCreateGridList(102, 40, 182, 89, false, PHONE.staticimage[1]) msgLabel = guiCreateLabel(102, 134, 182, 22, "Message:", false, PHONE.staticimage[1]) guiSetFont(msgLabel, "default-bold-small") guiLabelSetColor(msgLabel, 255, 0, 0) guiLabelSetHorizontalAlign(msgLabel, "center", false) guiLabelSetVerticalAlign(msgLabel, "center") msgText = guiCreateEdit(102, 160, 182, 173, "", false, PHONE.staticimage[1]) msgSend = guiCreateButton(102, 339, 182, 30, "Send!", false, PHONE.staticimage[1]) guiSetFont(msgSend, "default-bold-small") guiSetProperty(msgSend, "NormalTextColour", "FF1AEF0F") guiSetVisible(msgGRID,false) guiSetVisible(msgLabel,false) guiSetVisible(msgText,false) guiSetVisible(msgSend,false) function openMSG() if source == PHONE.staticimage[5] then guiSetVisible(msgGRID,true) guiSetVisible(msgLabel,true) guiSetVisible(msgText,true) guiSetVisible(msgSend,true) guiSetVisible(PHONE.staticimage[2],false) guiSetVisible(PHONE.staticimage[3],false) guiSetVisible(PHONE.staticimage[4],false) guiSetVisible(PHONE.staticimage[5],false) guiSetVisible(PHONE.staticimage[6],false) end end addEventHandler("onClientGUIClick",root,openMSG) function trigMSG() local msgPMText = guiGetText(msgText) local selectedRow, selectedColumn = guiGridListGetSelectedItem(msgGRID) local choosedPlayer = getPlayerFromName(guiGridListGetItemText(msgGRID, selectedRow, selectedColumn)) if source == msgSend then triggerServerEvent("onMessagePM",lp,msgPMText,choosedPlayer) end end addEventHandler("onClientGUIClick",root,trigMSG) function addXXXX() local column = guiGridListAddColumn( msgGRID, "Player", 0.85 ) if ( column ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( msgGRID ) guiGridListSetItemText ( msgGRID, row, column, getPlayerName ( playeritem ), false, false ) end end end addEventHandler ( "onClientResourceStart", resourceRoot, addXXXX ) server pmlimit = 5 function privmsgplayer(source, command, choosedPlayer,msgPMText, ...) if choosedPlayer then if getPlayerFromName(choosedPlayer) then if getElementData(source, sentpm) then outputChatBox("[PM-AntiSpam] Sorry, please wait to send another message.", source) return false end setElementData(source, sentpm, true) local pmtimer = pmlimit * 1000 or 5000 setTimer(removeElementData(source, sentpm), pmtimer, 1) outputChatBox("[PM] PM to " .. choosedPlayer .. ": " .. msgPMText, source, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(source) .. ": " .. msgPMText, getPlayerFromName(choosedPlayer), 255, 215, 0, false) else outputChatBox("[PM] Invalid syntax. try /pm ", source, 255, 0, 0, false) end else outputChatBox("[PM] The player specified does not exist in this server ("..choosedPlayer..").", source, 255, 0, 0, false) return false end end addEvent("onMessagePM",true) addEventHandler("onMessagePM",root,privmsgplayer) Link to comment
#meS Posted September 8, 2015 Author Share Posted September 8, 2015 BUMP this era doesn't have good scripters xDdddd Link to comment
LabiVila Posted September 8, 2015 Share Posted September 8, 2015 Hello there, first of all you've set: triggerServerEvent("onMessagePM",lp,msgPMText,choosedPlayer) - two arguments there, 'msgPMText' and 'choosedPlayer', while at server you have set 5 arguments, from there you can understand source == msgPMText and command == chosedPlayer, all other stuff is turned nil (choosedPlayer from serverside is nil, so is msgPMText and those three dots which I don't know why they are even there). So try fixing the arguments. Secondly, choosedPlayer is defined in client side, so 're-defining' it server side would make totally no sense. You either define it client side or server side, not both (getPlayerFromName (choosedPlayer)). Here I would as well suggest you to use https://wiki.multitheftauto.com/wiki/Ge ... artialName as it is much more advanced and useful, ignores color codes and stuff like that. Third, your lines 13 and 14 aren't so useful, you can't make a 'player name' receive the text, it must be a player element. so instead of your line 13 & 14, use these: outputChatBox("[PM] PM to " .. choosedPlayer .. ": " .. msgPMText, source, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(source) .. ": " .. msgPMText, getPlayerFromName(choosedPlayer), 255, 215, 0, false) outputChatBox ("PM to "..getPlayerFromName (choosedPlayer)..": "..msgPMText, source, 255, 0, 0, false) outputChatBox ("PM from "..getPlayerName (sourceplayer)..": "..msgPMText, choosedPlayer, 255, 0, 0, false) make sure to define sourceplayer, an easy way is to trigger that lp from client side Link to comment
#meS Posted September 10, 2015 Author Share Posted September 10, 2015 thanks but not working: server function privmsgplayer(source,msg,choosed) outputChatBox("[PM] PM to " .. getPlayerName(choosed) .. ": " .. msg, source, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(source) .. ": " .. msg, choosed, 255, 215, 0, false) end addEvent("onMessagePM",true) addEventHandler("onMessagePM",root,privmsgplayer) client function trigMSG() local selectedRow = guiGridListGetSelectedItem(msgGRID) local choosedPlayer = guiGridListGetItemData(msgGRID, selectedRow, 1) if source == msgSend then triggerServerEvent("onMessagePM",localPlayer,guiGetText(msgText),choosedPlayer) end end addEventHandler("onClientGUIClick",root,trigMSG) Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 triggerServerEvent("onMessagePM",localPlayer,guiGetText(msgText),choosedPlayer) You're sending the localPlayer as the base element, so the localPlayer will be pre-defined as source in the function. You have source as your first parameter, so, in this case, source is equal to the msgText's text. function privmsgplayer(msg,choosed) outputChatBox("[PM] PM to " .. getPlayerName(choosed) .. ": " .. msg, client, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(client) .. ": " .. msg, choosed, 255, 215, 0, false) end addEvent("onMessagePM",true) addEventHandler("onMessagePM",root,privmsgplayer) function trigMSG() if source == msgSend then local selectedRow = guiGridListGetSelectedItem(msgGRID) local choosedPlayer = guiGridListGetItemData(msgGRID, selectedRow, 1) triggerServerEvent("onMessagePM",resourceRoot,guiGetText(msgText),choosedPlayer) end end addEventHandler("onClientGUIClick",root,trigMSG) Link to comment
#meS Posted September 11, 2015 Author Share Posted September 11, 2015 so i can't pm my self :c? it gives me error when i pm my self it's not possible to pm your self or it's some thing wrong? Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 Is 'choosed' a string or a player element? What's the error? Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 Did you use guiGridListSetItemData anywhere? Post the code where you add rows. Link to comment
#meS Posted September 11, 2015 Author Share Posted September 11, 2015 function addXXXX() local column = guiGridListAddColumn( msgGRID, "Player", 0.85 ) if ( column ) then for id, playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( msgGRID ) guiGridListSetItemText ( msgGRID, row, column, getPlayerName ( playeritem ), false, false ) end end end addEventHandler ( "onClientResourceStart", resourceRoot, addXXXX ) Link to comment
JR10 Posted September 11, 2015 Share Posted September 11, 2015 You should be using guiGridListGetItemText to get the text of the selected row. function trigMSG() if source == msgSend then local selectedRow = guiGridListGetSelectedItem(msgGRID) local choosedPlayer = guiGridListGetItemText(msgGRID, selectedRow, 1) triggerServerEvent("onMessagePM",resourceRoot,guiGetText(msgText),choosedPlayer) end end addEventHandler("onClientGUIClick",root,trigMSG) function privmsgplayer(msg,choosed) local target = getPlayerFromName(choosed) if (not isElement(target)) then return end outputChatBox("[PM] PM to " .. choosed .. ": " .. msg, client, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(client) .. ": " .. msg, target, 255, 215, 0, false) end addEvent("onMessagePM",true) addEventHandler("onMessagePM",root,privmsgplayer) Link to comment
#meS Posted September 11, 2015 Author Share Posted September 11, 2015 You should be using guiGridListGetItemText to get the text of the selected row. function trigMSG() if source == msgSend then local selectedRow = guiGridListGetSelectedItem(msgGRID) local choosedPlayer = guiGridListGetItemText(msgGRID, selectedRow, 1) triggerServerEvent("onMessagePM",resourceRoot,guiGetText(msgText),choosedPlayer) end end addEventHandler("onClientGUIClick",root,trigMSG) function privmsgplayer(msg,choosed) local target = getPlayerFromName(choosed) if (not isElement(target)) then return end outputChatBox("[PM] PM to " .. choosed .. ": " .. msg, client, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(client) .. ": " .. msg, target, 255, 215, 0, false) end addEvent("onMessagePM",true) addEventHandler("onMessagePM",root,privmsgplayer) wow i'm so dumb thanks! Link to comment
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