Jump to content

Very very weird problem


jingzhi

Recommended Posts

Hey guys i am trying triggerclient to dxdraw a text here is the script

server

addEvent("register",true) 
addEvent("login",true) 
function register(username,password,player) 
    local newaccount = addAccount(username,password) 
    local username = username 
    local password = password 
    if newaccount ~= false then 
        logIn(player,newaccount,password) 
        setElementData(player,"username",username) 
        setElementData(player,"password",password) 
        triggerClientEvent(player,"successfulregistered",resourceRoot) 
    else 
        triggerClientEvent(player,"accountalreadyexist",resourceRoot) 
    end 
end 
addEventHandler("register",root,register) 
  

client

dxDrawText(""..getElementData(localPlayer,"username").."", 1008, 105, 1232, 142, tocolor(255, 255, 255, 255), 0.70, "bankgothic", "left", "top", false, false, false, false, false) 
    dxDrawText(""..getElementData(localPlayer,"password").."", 1008, 152, 1232, 189, tocolor(255, 255, 255, 255), 0.70, "bankgothic", "left", "top", false, false, false, false, false) 
end 

and the error :

line 1 of client script : "attempt to concatenate a boolean value"

Please help guys! Thank you very much

Link to comment

1) getElementData(localPlayer, "username") returns a boolean value (most probably 'false'). 'false [bool]' cannot be concatenated (joined up) with a string, unless you tostring() it,

e.g.

""..tostring(getElementData(localPlayer, "username")).."" 

2) It seems redundant (and probably inefficient) to concatenate a value to 2 empty strings...

You could just go ahead and type

getElementData(localPlayer,"username") 

instead of

""..getElementData(localPlayer,"username").."" 

I'm assuming you've shared a section of the code (some lines seem to be pleonastic, or do not have a starting point — e.g. you have an 'end' which doesn't start anywhere) as it doesn't seem one bit complete.

Link to comment
1) getElementData(localPlayer, "username") returns a boolean value (most probably 'false'). 'false [bool]' cannot be concatenated (joined up) with a string, unless you tostring() it,

e.g.

""..tostring(getElementData(localPlayer, "username")).."" 

2) It seems redundant (and probably inefficient) to concatenate a value to 2 empty strings...

You could just go ahead and type

getElementData(localPlayer,"username") 

instead of

""..getElementData(localPlayer,"username").."" 

I'm assuming you've shared a section of the code (some lines seem to be pleonastic, or do not have a starting point — e.g. you have an 'end' which doesn't start anywhere) as it doesn't seem one bit complete.

Hey yes i am wondering why it will return a boolean :| , and this is not the full script

Link to comment
Why don't you try fetching account name from serverside? like in server part add this:
local acc = getAccountName(getPlayerAccount(source)) 

I prefer this one because its the better way instead of using element data.

Before I put them as elementdata, i tryed to pass them down by putting them in the arguments of triggerclientevent, but it says that its nil, i will try this out, i will tell you if it works

Link to comment
Why don't you try fetching account name from serverside? like in server part add this:
local acc = getAccountName(getPlayerAccount(source)) 

I prefer this one because its the better way instead of using element data.

Hey ryan but how about the password? I also want to show the player the password for his acc

Link to comment
In that case, you'll have to learn database a bit, then loop through mta's default database and that too, contains protected forms of passwords, i guess that protection is called md5 or something:

OfeTO7a.png

I see, ty Ryan, do you recommend SQLlite?

SQLite or MySQL will work the same. SQLite is better if you don't want to install other software (XAMPP/WAMP/etc..), however you would have to download the file if you want to view it. MySQL is better if you want to be able to access your database through a website, but it requires a little more setup, and it may not be as fast as SQLite.

Link to comment
Check out my post regarding SQLite vs MySQL: https://forum.multitheftauto.com/viewtopic.php?f ... 42#p772442

Also, @xXMADEXx if i'm not wrong, a MySQL connection can also be obtained online (apart from offline XAMPP, etc) by having a free domain from any free webhost right? Like hostinger or 00webhost.

Thank you very much, ryan, I have a little extra problem, of your Live Weather script, how do you fetch the weathr info from a website? Thanks :)

Link to comment
In that case, you'll have to learn database a bit, then loop through mta's default database and that too, contains protected forms of passwords, i guess that protection is called md5 or something:

OfeTO7a.png

I see, ty Ryan, do you recommend SQLlite?

SQLite or MySQL will work the same. SQLite is better if you don't want to install other software (XAMPP/WAMP/etc..), however you would have to download the file if you want to view it. MySQL is better if you want to be able to access your database through a website, but it requires a little more setup, and it may not be as fast as SQLite.

I see, thank you very much, is there a tutorial of setting up MySQL in the forum?

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