Oxsotus Posted July 6, 2013 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)
Castillo Posted July 6, 2013 Posted July 6, 2013 You're making a MySQL query every time you use that chat? that's really inefficient. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Oxsotus Posted July 6, 2013 Author 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"
Dealman Posted July 7, 2013 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
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