FUNExtreme Posted May 3, 2010 Posted May 3, 2010 Hello, I have a problem getting a boolean out of a map file and then using it in a function -- Blah blah (loop here) local newTeam = createTeam(tostring(getElementData(s, "name")), tonumber(getElementData(s, "colourR")), tonumber(getElementData(s, "colourG")), tonumber(getElementData(s, "colourB"))) setTeamFriendlyFire(newTeam, tostring(getElementData(s, "friendlyFire"))) but it always says bad argument, I tried, tonumber, tostring and all that but I actually need toboolean wich doesn't exist in MTA lua. The .map contains .... friendlyFire="true" .... I have allready made a workaround to fix this problem but I want to know if it is possible to do it like I state above. (Using a boolean in the .map file and then just getting it)
dzek (varez) Posted May 3, 2010 Posted May 3, 2010 tostring ... returns .. STRING --- [sUPRISE!!] and you need boolean toboolean should do the job (im not sure about its name, but it was something like that?) or just remove that tostring - and it should work Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
robhol Posted May 3, 2010 Posted May 3, 2010 tostring ... returns .. STRING --- [sUPRISE!!] and you need booleantoboolean should do the job (im not sure about its name, but it was something like that?) or just remove that tostring - and it should work There's no toboolean.. if it returns a string, check whether it's "true". For extra "security" you can also check if it's "false". (If it's neither, you're obviously getting something unexpected.) Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
FUNExtreme Posted May 3, 2010 Author Posted May 3, 2010 As I wrote before I checked all the options allready but here are the answers tostring returns correctly wich means that it shows "true" or "false" when used in outputDebugString using nothing but just the getElementData also returns "true" or "false" when used in outputDebugString although when I use it in setTeamFriendlyFire it gives bad argument. and as robhol stated (so did I in the first post) toboolean doesn't exist
dzek (varez) Posted May 3, 2010 Posted May 3, 2010 and as robhol stated (so did I in the first post) toboolean doesn't exist hmm, maybe, i never need that, but in lua's manual i found something like that, thats why i wrote it here Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
robhol Posted May 3, 2010 Posted May 3, 2010 It doesn't exist... However, for example, you could do something like function toboolean(x) if x == "true" then return true; end if x == "false" then return false; end error("toboolean: unexpected input: " .. tostring(x) ); end Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
karlis Posted May 3, 2010 Posted May 3, 2010 function from dxspeedometer resource: function toboolean(bool) if bool=="true" or bool==1 or bool==true then return true end return false end [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
Dark Dragon Posted May 3, 2010 Posted May 3, 2010 -- Blah blah (loop here) local newTeam = createTeam(tostring(getElementData(s, "name")), tonumber(getElementData(s, "colourR")), tonumber(getElementData(s, "colourG")), tonumber(getElementData(s, "colourB"))) setTeamFriendlyFire(newTeam, tostring(getElementData(s, "friendlyFire"))=="true") and if you change the map file to friendlyFire="[true]" this should be enough: -- Blah blah (loop here) local newTeam = createTeam(tostring(getElementData(s, "name")), tonumber(getElementData(s, "colourR")), tonumber(getElementData(s, "colourG")), tonumber(getElementData(s, "colourB"))) setTeamFriendlyFire(newTeam, getElementData(s, "friendlyFire")) Loads of fun for free! Also a lot of fun for free!
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