Jump to content

I can't find a mistake in this script!!!


Recommended Posts

4V4PMON.png

function HunterInfo(source, hunters, person) 
  
    if person == nil and getAccountData(getPlayerAccount(source),"hunter.counts") == false then 
        outputChatBox("#FFFFFFYou did not reach the Hunter yet.", source, 255,255,255,true) 
    elseif person == nil and getAccountData(getPlayerAccount(source),"hunter.counts") == 1 then 
        outputChatBox("#FFFFFFYou have reached the Hunter#FF0000 "..getAccountData(getPlayerAccount(source),"hunter.counts").." #FFFFFFtime.",source,255,255,255,true) 
    elseif person == nil and getAccountData(getPlayerAccount(source),"hunter.counts") > 1 then 
        outputChatBox("#FFFFFFYou have reached the Hunter#FF0000 "..getAccountData(getPlayerAccount(source),"hunter.counts").." #FFFFFFtimes.",source,255,255,255,true) 
    elseif getAccountData(getPlayerAccount(getPlayerFromName(person)),"hunter.counts") == false then 
        outputChatBox(getPlayerName(getPlayerFromName(person)).." #FFFFFFdid not reach the Hunter yet.", source, 255, 255, 255,true) 
    elseif getAccountData(getPlayerAccount(getPlayerFromName(person)),"hunter.counts") == 1 then 
        outputChatBox(getPlayerName(getPlayerFromName(person)).." #FFFFFFhas reached the Hunter #FF0000"..getAccountData(getPlayerAccount(getPlayerFromName(person)),"hunter.counts").." #FFFFFFtime.", source, 255, 255, 255,true) 
    elseif getAccountData(getPlayerAccount(getPlayerFromName(person)),"hunter.counts") > 1 then 
        outputChatBox(getPlayerName(getPlayerFromName(person)).." #FFFFFFhas reached the Hunter #FF0000"..getAccountData(getPlayerAccount(getPlayerFromName(person)),"hunter.counts").." #FFFFFFtimes.", source, 255, 255, 255,true) 
    else 
        outputChatBox("Sytanx: /hunters [Player]", source, 255, 0, 0,false) 
    end 
end 
addCommandHandler("hunters", HunterInfo) 
  

When the hunter.counts is 0 it should display that player didn't reach hunter yet, and when player tries /hunter [person] it should show the same if they don't have hunter.

Its not working :/

Line 30 = line 9 btw

Link to comment

"getPlayerFromName(person)" - is using direct comparation between all player's and the gived name. So when you type in the name , you need to type the color cod's to.

If you name is #00ff00Me , and you type in Me , it will not find you bk you don't entered the color code.

Link to comment

Try this:

function HunterInfo ( source, _, person ) 
    local person = getPlayerFromName ( person ) 
    local account = getPlayerAccount ( source ) 
    if ( not person and not getAccountData ( account, "hunter.counts" ) ) then 
        outputChatBox ( "#FFFFFFYou did not reach the Hunter yet.", source, 255, 255, 255, true ) 
    elseif ( not person and getAccountData ( account, "hunter.counts" ) == 1 ) then 
        outputChatBox ( "#FFFFFFYou have reached the Hunter#FF0000 ".. getAccountData ( account, "hunter.counts" ) .." #FFFFFFtime.", source, 255, 255, 255, true ) 
    elseif ( not person and getAccountData ( account, "hunter.counts" ) > 1 ) then 
        outputChatBox ( "#FFFFFFYou have reached the Hunter#FF0000 ".. getAccountData ( account, "hunter.counts" ) .." #FFFFFFtimes.", source, 255, 255, 255, true ) 
    elseif ( not getAccountData ( getPlayerAccount ( person ), "hunter.counts" ) ) then 
        outputChatBox ( getPlayerName ( person ) .." #FFFFFFdid not reach the Hunter yet.", source, 255, 255, 255, true ) 
    elseif ( getAccountData ( getPlayerAccount ( person ), "hunter.counts" ) == 1 ) then 
        outputChatBox ( getPlayerName ( person ) .." #FFFFFFhas reached the Hunter #FF0000".. getAccountData ( getPlayerAccount ( person ), "hunter.counts" ) .." #FFFFFFtime.", source, 255, 255, 255, true ) 
    elseif ( getAccountData ( getPlayerAccount ( person ), "hunter.counts" ) > 1 ) then 
        outputChatBox ( getPlayerName ( person ) .." #FFFFFFhas reached the Hunter #FF0000".. getAccountData ( getPlayerAccount ( person ), "hunter.counts" ) .." #FFFFFFtimes.", source, 255, 255, 255, true ) 
    else 
        outputChatBox ( "Sytanx: /hunters [Player]", source, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "hunters", HunterInfo ) 

Link to comment
Didn't work Snake.

I'm a C programmer and pretty new to Lua, what i found out that Lua got a weird thing on its language

== false

== 0

== false or 0 < This will never work on getAccountData

Not sure if its a bug or probably my mistake, thanks anyway

in C/C++ false = 0 if you use it in "if" , in lua it's note .

Anyway :" getAccountData(....) or 0 " is working

Link to comment

In Lua, numbers don't represent anything else than that: numbers. Boolean values are either true or false (it is case-sensitive, so TRUE and FALSE is not valid).

in C/C++ false = 0 if you use it in "if"

In C/C++, false always represents 0, no matter where you use it.

Link to comment

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