Jump to content

setElementData


UAEpro

Recommended Posts

Posted (edited)
function rankk() 
local gotexp2 = getElementData(source,"exp212") 
if gotexp2 == 1 then 
outputChatBox(gotexp2) 
outputChatBox("*sorry",source,0,255,0,true) 
else 
outputChatBox("ok",source,0,255,0,true) 
setElementData(source,"exp212",1) 
end 
end 
addEventHandler("onPlayerWasted",getRootElement(),rankk) 
  
  
function new() 
  
setElementData(source,"exp212",0) 
alvw = getElementData(source,"exp212") 
outputChatBox(""..alvw) 
end 
addEvent("onMapStarting",true) 
addEventHandler("onMapStarting",getRootElement(),new) 

it always show "sorry"

idk why o.O

another stupid problem

Edited by Guest
Posted
function rankk() 
local gotexp2 = tonumber(getElementData(source,"exp212")) 
if (gotexp2 == 1) then 
outputChatBox(gotexp2) 
outputChatBox("*sorry",source,0,255,0,true) 
else 
outputChatBox("ok",source,0,255,0,true) 
setElementData(source,"exp212",1) 
end 
end 
addEventHandler("onPlayerWasted",getRootElement(),rankk) 
  
function new() 
setElementData(source,"exp212",0) 
alvw = getElementData(source,"exp212") 
outputChatBox(""..alvw) 
end 
addEvent("onMapStarting",true) 
addEventHandler("onMapStarting",getRootElement(),new) 

Posted

1st getElementData(source,"exp212") must be nill

it will say sorry in the chatbox

then the value will be 1

so it will not say sorry again until another map start

but it's not working

Posted
function rankk( ) 
    local gotexp2 = tonumber( getElementData( source,"exp212" ) or 0 ) 
    if gotexp2 == 1 then -- you can use if some then instand of if ( some ) then 
        outputChatBox( tostring( gotexp2 ) ) -- gotexp2 is number value convert to string 
        --outputChatBox( "*sorry",source,0,255,0,true ) -- why true ? Need use false see in arguments function 
        outputChatBox( "*sorry",source,0,255,0 )  
    else 
        --outputChatBox("ok",source,0,255,0,false ) -- same 
        outputChatBox( "ok",source,0,255,0 ) 
        setElementData( source,"exp212",1 ) 
    end 
end 
addEventHandler( "onPlayerWasted",root,rankk )  
  
function new( ) 
    setElementData( source,"exp212",0 ) 
    local alvw = getElementData( source,"exp212" ) -- variable alvw is number  
    outputChatBox( tostring( alvw ) ) -- convert to string 
end 
addEvent( "onMapStarting",true) 
addEventHandler( "onMapStarting",root,new ) 

SolidShake14,Your code is wrong ...

P.S Tabulate your code in next time.

P.S See in /debugscript 3

P.S Code updated.

Posted

the problem is not from the value or outputchatbox

..

i put outputchatbox to know what is the element

i just care about

(( if gotexp2 == 1 then ))

it's always 1 even when i change the value in onMapStarting

Posted
function rankk( ) 
    local gotexp2 = tonumber( getElementData( source,"exp212" ) or 0 ) 
    if gotexp2 == 1 then -- you can use if some then instand of if ( some ) then 
        outputChatBox( tostring( gotexp2 ) ) -- gotexp2 is number value convert to string 
        --outputChatBox( "*sorry",source,0,255,0,true ) -- why true ? Need use false see in arguments function 
        outputChatBox( "*sorry",source,0,255,0 )  
    else 
        --outputChatBox("ok",source,0,255,0,false ) -- same 
        outputChatBox( "ok",source,0,255,0 ) 
        setElementData( source,"exp212",1 ) 
    end 
end 
addEventHandler( "onPlayerWasted",root,rankk )  
  
function new( ) 
    setElementData( source,"exp212",0 ) 
    local alvw = getElementData( source,"exp212" ) -- variable alvw is number  
    outputChatBox( tostring( alvw ) ) -- convert to string 
end 
addEvent( "onMapStarting",true) 
addEventHandler( "onMapStarting",root,new ) 

SolidShake14,Your code is wrong ...

P.S Tabulate your code in next time.

P.S See in /debugscript 3

P.S Code updated.

That's just useless, true and false in outputChatBox will just enable and disable the HEX color codes.

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