Jump to content

Boolean to string


Recommended Posts

I have problem with boolean, I think I must convert this to string, right? Whats function do this?

[2012-06-26 19:28:53] ERROR: social-system/s_friends.lua:203: attempt to concatenate a boolean value 

[2012-06-26 19:44:04] ERROR: lses-system/s_lves_system.lua:26: attempt to concatenate a boolean value 

Link to comment

Mate maybe learn to script before you make a roleplay server or you will get know were, and we cant find out the function for you because we dont have the script go look for the function yourself. It is not hard to find a function maybe go to the line where the error is :/

P.S.

Learn To Script

Link to comment

I want to learn LUA on RP script, thats why I ask on this forum.

Friends:

addEvent( "social:message", true ) 
addEventHandler( "social:message", root, 
    function( message ) 
        local accountID = getElementData( client, "account:id" ) 
        if accountID and friends[ accountID ] then 
[u][b]          if mysql:query_free("UPDATE accounts SET friendsmessage = '" .. mysql:escape_string(message) .. "' WHERE id = " .. mysql:escape_string(accountID) ) then[/u][/b] 
                friends[ accountID ].message = message 
                notifyFriendsOf( client, accountID, "social:message", message ) 
                 
                triggerClientEvent( client, "social:message", client, accountID, message ) 
            end 
        end 
    end 
) 

lses:

  
function playerDeath(totalAmmo, killer, killerWeapon) 
...(anothercode)... 
  
            local affected = { } 
            table.insert(affected, source) 
            local killstr = ' died' 
            if (killer) then 
                [u][b]killstr = ' got killed by '..getPlayerName(killer).. ' ('..getWeaponNameFromID ( killerWeapon )..')'[/b][/u] 
                table.insert(affected, killer) 
            end 

Link to comment
I want to learn LUA on RP script, thats why I ask on this forum.

Friends:

addEvent( "social:message", true ) 
addEventHandler( "social:message", root, 
    function( message ) 
        local accountID = getElementData( client, "account:id" ) 
        if accountID and friends[ accountID ] then 
[u][b]          if mysql:query_free("UPDATE accounts SET friendsmessage = '" .. mysql:escape_string(message) .. "' WHERE id = " .. mysql:escape_string(accountID) ) then[/u][/b] 
                friends[ accountID ].message = message 
                notifyFriendsOf( client, accountID, "social:message", message ) 
                 
                triggerClientEvent( client, "social:message", client, accountID, message ) 
            end 
        end 
    end 
) 

lses:

  
function playerDeath(totalAmmo, killer, killerWeapon) 
...(anothercode)... 
  
            local affected = { } 
            table.insert(affected, source) 
            local killstr = ' died' 
            if (killer) then 
                [u][b]killstr = ' got killed by '..getPlayerName(killer).. ' ('..getWeaponNameFromID ( killerWeapon )..')'[/b][/u] 
                table.insert(affected, killer) 
            end 

You wont learn lua copying and pasting i learnt that a bit ago

Link to comment
Yes you're right, thats why I ask in first post for a function or the way how do it (or something like this - habits from Pawn and SAMP) not for code prepared by You. I want learn, not have script.

Yes but your asking for the function when we dont even know what the script is maybe go have a look at the error line

Link to comment
Guest Guest4401
I have problem with boolean, I think I must convert this to string, right?

No.

I don't know what micheal1230 and karthik_184 want when they ask you to show your code, but that's not needed. To convert the value to string, use function tostring and pass the value as the first argument.

Converting a boolean value to string won't solve the purpose in this case.

local str = "abc"..false.."d" 
-- attempt to concatenate on a boolean value 
  
local str = "abc"..tostring(false).."d" 
-- "abcfalsed" 

And I don't think anyone would wish outputting something like that.

_______________________________________________

@nightmare12

The error was being shown because something returned false, which I assume should be getWeaponNameFromID(killerWeapon) since there's no weapon used at all.

Try this:

function playerDeath(totalAmmo, killer, killerWeapon) 
    local affected = { } 
    table.insert(affected, source) 
    local killstr = ' died' 
    local killerE 
    if isElement(killer) and getElementType(killer) == "vehicle" then 
        killerE = getVehicleController(killer) 
    elseif isElement(killer) and getElementType(killer) == "player" then 
        killerE = killer 
    end 
    if (killerE) then 
        local weaponName = getWeaponNameFromID ( killerWeapon ) 
        if weaponName then -- if there was a weapon used 
            killstr = ' got killed by '..getPlayerName(killerE).. ' ('..weaponName..')' 
        else -- if there was no weapon used 
            killstr = ' got killed by '..getPlayerName(killerE) 
        end 
        table.insert(affected, killerE) 
    end 
end 

Similarly, there must be a boolean value in between the string in the file "friends" too.

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