Oxsotus Posted July 6, 2013 Share Posted July 6, 2013 Hi! I have one problem. I want to create a chat for medics, polices, etc etc... Here the function: first line function mentos_chat(jatekos,parancs,uzenet) (in english uzenet = message) So, I wrote the chat's command, and the message : "/mc Hello everybody" And it's only write the word "hello". I know, the first variable (uzenet) = Hello, and because the space the word "everybody" is the second variable, which does not exist. So, my question is: how to set the variable "uzenet" to text? Here's the full code: function mentos_chat(jatekos,parancs,uzenet) jatekos_adats_keres = dbQuery( adatbazis, "SELECT * FROM `players` WHERE `Username`=?", getPlayerName(jatekos) ) jatekos_adats = dbPoll( jatekos_adats_keres, -1 ) akik_ = dbQuery( adatbazis, "SELECT * FROM `players` WHERE `leaderes_munka`=?", 2) akik, row = dbPoll( akik_, -1 ) outputChatBox(row,jatekos) for i = 1, row, 1 do if( isPlayerOnline(akik[i].Username) then if(jatekos_adats[1].leaderes_rang == 1) then outputChatBox("Rádió: Próbaidős "..jatekos_adats[1].Character..": "..uzenet,getPlayerFromName(akik[i].Username)) end if(jatekos_adats[1].leaderes_rang == 2) then outputChatBox("Rádió: Ápoló "..jatekos_adats[1].Character..": "..uzenet,getPlayerFromName(akik[i].Username)) end if(jatekos_adats[1].leaderes_rang == 3) then outputChatBox("Rádió: Mentős "..jatekos_adats[1].Character..": "..uzenet,getPlayerFromName(akik[i].Username)) end if(jatekos_adats[1].leaderes_rang == 4) then outputChatBox("Rádió: Orvos "..jatekos_adats[1].Character..": "..uzenet,getPlayerFromName(akik[i].Username)) end if(jatekos_adats[1].leaderes_rang == 5) then outputChatBox("Rádió: Főnök "..jatekos_adats[1].Character..": "..uzenet,getPlayerFromName(akik[i].Username)) end outputChatBox(akik[i].Username,jatekos) end end end addCommandHandler("mc",mentos_chat) Link to comment
Castillo Posted July 6, 2013 Share Posted July 6, 2013 You're making a MySQL query every time you use that chat? that's really inefficient. Link to comment
Oxsotus Posted July 6, 2013 Author Share Posted July 6, 2013 Yes, because if add a player example to the medics, I can't refresh the other player's side "jatekos_adats" var, and the player must reconnect to the server to update the "jatekos_adats" Link to comment
Dealman Posted July 7, 2013 Share Posted July 7, 2013 Replace uzenet with ..., so it looks like this; function mentos_chat(jatekos, parancs, ...) Then you simply add this; local message = table.concat({...}, " ") This way it won't break when there's a space. 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