CodX Posted July 10, 2017 Share Posted July 10, 2017 (edited) Hello ! I want to make an Event-System for my MTA Server but i don't know how can i add a condition (when the player write "event", then teleport) function event(thePlayer, commandName, ...) if (exports.integration:isPlayerLeadAdmin(thePlayer)) then local playerName = getPlayerName ( thePlayer ) outputChatBox("Adminul '" .. playerName.. "' testeaza un script personal.", source, 255, 194, 14) outputChatBox("Scrie /participa pentru a participa !", source, 255, 194, 14) else outputChatBox("Trebuie sa fi 'Lider Admin' pentru a avea acces la '/event'", thePlayer, 255, 194, 14) outputChatBox("Script creat de 'Griffin_Connor'.", thePlayer, 255, 194, 14) end end addCommandHandler("event", event) ) Logs: SCRIPT ERROR: event-system2/event.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>' ERROR: Loading script failed: event-system2/event.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>' Edited July 10, 2017 by CodX I've changed something. Link to comment
Ayush Rathore Posted July 10, 2017 Share Posted July 10, 2017 (edited) 29 minutes ago, CodX said: Hello ! I want to make an Event-System for my MTA Server but i don't know how can i add a condition (when the player write "event", then teleport) function event(thePlayer, commandName, ...) if (exports.integration:isPlayerLeadAdmin(thePlayer)) then local playerName = getPlayerName ( thePlayer ) outputChatBox("Adminul '" .. playerName.. "' testeaza un script personal.", thePlayer, 255, 194, 14) outputChatBox("Scrie /event pentru a participa !", thePlayer, 255, 194, 14) if (thePlayer == "/event" and exports.integration:isPlayerLeadAdmin(thePlayer)) then outputChatBox("Test", thePlayer, 255, 194, 14) else outputChatBox("Trebuie sa fi 'Lider Admin' pentru aceasta comanda !", thePlayer, 255, 194, 14) outputChatBox("Script creat de 'Griffin_Connor'.", thePlayer, 255, 194, 14) end end addCommandHandler("event", event) Logs: SCRIPT ERROR: event-system2/event.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>' ERROR: Loading script failed: event-system2/event.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>' first read how to post in this forum your code hurt my eyes and also go to mta wiki to learn some coding btw let me help you function joinEvent(thePlayer, commandName, ...) if (exports.integration:isPlayerLeadAdmin(thePlayer)) then local playerName = getPlayerName ( thePlayer ) outputChatBox("Adminul '" .. playerName.. "' testeaza un script personal.", thePlayer, 255, 194, 14) outputChatBox("Scrie /event pentru a participa !", thePlayer, 255, 194, 14) outputChatBox("Test", thePlayer, 255, 194, 14) else outputChatBox("Trebuie sa fi 'Lider Admin' pentru aceasta comanda !", thePlayer, 255, 194, 14) outputChatBox("Script creat de 'Griffin_Connor'.", thePlayer, 255, 194, 14) end end addCommandHandler("event", joinEvent) this should be correct as i don't know your language . Edited July 10, 2017 by Ayush Rathore 1 Link to comment
CodX Posted July 10, 2017 Author Share Posted July 10, 2017 My language is Romanian. I want to add a condition. For example: I type /participa , participa = participate, and then teleport me or other player to x, y, z. I've tried to add if ({participa}) then --teleport-- I don't how to make this condition with teleport. Can you help me please ? Scrip modify: function joinEvent(thePlayer, commandName, ...) if (exports.integration:isPlayerLeadAdmin(thePlayer) and {event}) then local playerName = getPlayerName ( thePlayer ) outputChatBox("Adminul '" .. playerName.. "' testeaza un script personal.", source, 255, 194, 14) outputChatBox("Scrie /participa pentru a participa !", source, 255, 194, 14) else outputChatBox("Trebuie sa fi 'Lider Admin' pentru a avea acces la '/event'", thePlayer, 255, 194, 14) outputChatBox("Script creat de 'Griffin_Connor'.", thePlayer, 255, 194, 14) end if({participa}) then outputChatBox("Test", thePlayer, 255, 194, 14) end end addCommandHandler("event", joinEvent) addCommandHandler("participa", joinEvent) Link to comment
Ayush Rathore Posted July 10, 2017 Share Posted July 10, 2017 (edited) 25 minutes ago, CodX said: My language is Romanian. I want to add a condition. For example: I type /participa , participa = participate, and then teleport me or other player to x, y, z. I've tried to add if ({participa}) then --teleport-- I don't how to make this condition with teleport. Can you help me please ? Scrip modify: function joinEvent(thePlayer, commandName, ...) if (exports.integration:isPlayerLeadAdmin(thePlayer) and {event}) then local playerName = getPlayerName ( thePlayer ) outputChatBox("Adminul '" .. playerName.. "' testeaza un script personal.", source, 255, 194, 14) outputChatBox("Scrie /participa pentru a participa !", source, 255, 194, 14) else outputChatBox("Trebuie sa fi 'Lider Admin' pentru a avea acces la '/event'", thePlayer, 255, 194, 14) outputChatBox("Script creat de 'Griffin_Connor'.", thePlayer, 255, 194, 14) end if({participa}) then outputChatBox("Test", thePlayer, 255, 194, 14) end end addCommandHandler("event", joinEvent) addCommandHandler("participa", joinEvent) Sure i will help u but seriously u don't know scripting, local commands = { ['event'] = true, ['participate'] = true } function checkForEventJoining(commandName) if commands[commandName] then local playerResponsible = source if commandName == "event" then if (exports.integration:isPlayerLeadAdmin(playerResponsible)) then local playerName = getPlayerName ( playerResponsible ) outputChatBox("Admin Joined the Event Script Works!", playerResponsible, 255, 194, 14) else outputChatBox("You need Admin for joining event!", playerResponsible, 255, 194, 14) end elseif commandName == "participate" then if (exports.integration:isPlayerLeadAdmin(playerResponsible)) then local playerName = getPlayerName ( playerResponsible ) outputChatBox("Admin participated Script Works!", playerResponsible, 255, 194, 14) else outputChatBox("You need Admin for participating in event!", playerResponsible, 255, 194, 14) end end end end addEventHandler("onPlayerCommand", root, checkForEventJoining) help yourself by learning scripting and also see above how to do it Please re read my post as i edited it Edited July 10, 2017 by Ayush Rathore 2 Link to comment
CodX Posted July 10, 2017 Author Share Posted July 10, 2017 Works ! Thank you ! And yes, i need to learn lua. I'm beginner. At school i learn C++ so i've used the bases of that language. Thank you again ! Very much ! 1 Link to comment
Ayush Rathore Posted July 10, 2017 Share Posted July 10, 2017 6 minutes ago, CodX said: Works ! Thank you ! And yes, i need to learn lua. I'm beginner. At school i learn C++ so i've used the bases of that language. Thank you again ! Very much ! Any time no problem your welcome 1 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