Jump to content

small help


WASSIm.

Recommended Posts

Posted

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 
) 

Posted
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
Posted

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.

Posted
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 
) 

Posted
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 

Posted

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!

Posted
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

Posted
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!

Posted
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)

Posted

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 
) 

Posted

thank you :D

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) 

Posted
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) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...