WASSIm. Posted July 3, 2013 Posted July 3, 2013 hi guys i have this script but not working ! why ? addEventHandler('onPlayerConnect', getRootElement(), function() local country = exports.admin:getPlayerCountry(source) if (country == SA) then cancelEvent( true, "this server not allowed to your country!" ) end end )
codeluaeveryday Posted July 3, 2013 Posted July 3, 2013 addEventHandler('onPlayerConnect', getRootElement(), function() local country = exports.admin:getPlayerCountry(source) if (country == 'SA') then cancelEvent( true, "Your not allowed to enter this server from Saudi Arabia" ) end end )
Moderators IIYAMA Posted July 3, 2013 Moderators Posted July 3, 2013 Why don't you first run a test? Check if the name is correct. addEventHandler('onPlayerConnect', root, function() local country = exports.admin:getPlayerCountry(source) outputChatBox(tostring(country) or "problems with admin, failed to receive correct information") end ) Tell me what it returns in the chatbox.
WASSIm. Posted July 3, 2013 Author Posted July 3, 2013 Why don't you first run a test? Check if the name is correct. Tell me what it returns in the chatbox. if make this. its working 100% addEventHandler('onPlayerConnect', getRootElement(), function() local country = exports.admin:getPlayerCountry(source) if not (country == SA) then cancelEvent( true, "this server not allowed to your country!" ) end end )
WASSIm. Posted July 3, 2013 Author Posted July 3, 2013 "country" is returning "SA"? SA is (saudi arabia) is country
WASSIm. Posted July 3, 2013 Author Posted July 3, 2013 I know what it means, does the script work now? no if make this working if not (country == SA) then but i want this but not working if (country == SA) then
AMARANT Posted July 3, 2013 Posted July 3, 2013 Man, check the returned value of exports.admin:getPlayerCountry(source) with outputChatBox! When you see what it outputs then it'll be easier to help you!
WASSIm. Posted July 3, 2013 Author Posted July 3, 2013 Man, check the returned value of exports.admin:getPlayerCountry(source) with outputChatBox! When you see what it outputs then it'll be easier to help you! show me nothing
iPrestege Posted July 3, 2013 Posted July 3, 2013 addEventHandler('onPlayerConnect', getRootElement(), function() local country = exports.admin:getPlayerCountry(source) if (country == SA) then cancelEvent( true, "this server not allowed to your country!" ) outputChatBox ( country,root ) end end ) see what output!
Castillo Posted July 3, 2013 Posted July 3, 2013 See what 'source' returns. outputDebugString ( getPlayerName ( source ) ) Also you must check == "SA" not == SA.
WASSIm. Posted July 4, 2013 Author Posted July 4, 2013 On server console, do you see something? [02:05:57] WARNING: [admin]/admin/server/admin_ip2c.lua:19: Bad argument @ 'gettok' [02:05:57] WARNING: [admin]/admin/server/admin_ip2c.lua:20: Bad argument @ 'gettok' [02:05:57] ERROR: [admin]/admin/server/admin_ip2c.lua:20: attempt to perform arithmetic on a boolean value [02:05:57] ERROR: call: failed to call 'admin:getPlayerCountry' [string "?"] [02:05:57] CONNECT: WASSIm. connected (IP: 41.226.214.184 Serial: ****** Version: 1.3.3-9.05588.0) [02:05:57] JOIN: WASSIm. joined the game (IP: 41.226.214.184)
Castillo Posted July 4, 2013 Posted July 4, 2013 Must be because 'source' is not a player element. You can do this though, go to the admin resource and open up the meta.xml, then add this: function="getIpCountry"/> Then use this script: addEventHandler ( 'onPlayerConnect', getRootElement(), function ( _, ip ) local country = exports.admin:getIpCountry ( ip ) if ( country == "SA" ) then cancelEvent ( true, "this server not allowed to your country!" ) end end )
WASSIm. Posted July 4, 2013 Author Posted July 4, 2013 thank you can help me for this he tell me Bad argument @ 'getTeamName' policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true,[288]=true } soldiereSkins = { [287]=true } staffSkins = { [217]=true,[211]=true } function informPlayerOnModelChange(oldModel, newModel) if ( getElementType(source) == "player" ) then local Playerteam = getPlayerTeam(source) if (Playerteam) then local Teamname = getTeamName(playerTeam) if not (Teamname == "Police") and (policeSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only policeman can use this skin!", source, 255, 0, 0) elseif not (Teamname == "Armed Forces") and (soldiereSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only Soldier can use this skin!", source, 255, 0, 0) elseif not (Teamname == "STAFF") and (staffSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only STAFF can use this skin!", source, 255, 0, 0) end end end end addEventHandler("onElementModelChange", root, informPlayerOnModelChange)
WASSIm. Posted July 4, 2013 Author Posted July 4, 2013 playerTeam > PlayerTeamp > 'P' ! Oh i fixed this now but not working
WASSIm. Posted July 4, 2013 Author Posted July 4, 2013 Ok post the code. policeSkins = { [280]=true,[281]=true,[282]=true,[283]=true,[284]=true,[285]=true,[286]=true,[288]=true } soldiereSkins = { [287]=true } staffSkins = { [217]=true,[211]=true } function informPlayerOnModelChange(oldModel, newModel) if ( getElementType(source) == "player" ) then local PlayerTeam = getPlayerTeam(source) if (PlayerTeam) then local Teamname = getTeamName(PlayerTeam) if not (Teamname == "Police") and (policeSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only policeman can use this skin!", source, 255, 0, 0) elseif not (Teamname == "Armed Forces") and (soldiereSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only Soldier can use this skin!", source, 255, 0, 0) elseif not (Teamname == "STAFF") and (staffSkins[newModel]) then setElementModel ( source, oldModel ) outputChatBox ( "Only STAFF can use this skin!", source, 255, 0, 0) end end end end addEventHandler("onElementModelChange", root, informPlayerOnModelChange)
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