K4stic Posted February 9, 2013 Share Posted February 9, 2013 says on line 12: attempt to concatenate a boolean value --Server side function sortTimerj(plr,timer,time) if timer and time then if isTimer(timerjTimer) then killTimer(timerjTimer) end timerjTimer = setTimer(function(plr) time = time - 70 m,s,cs = msToTimeStr(time) fullTime = m..":"..s textItemSetText(timer,"Time Left : "..tostring(fullTime).."") if plr then setElementData(getResourceRootElement(getThisResource()),""..getPlayerSerial(plr).."-t",time) end if ( tonumber(m) <= 0 and tonumber(s) <= 0 and tonumber(cs) <= 0 ) then onTimerFinish(plr,timer) end end , 50 , 0 ,plr ) end end Link to comment
3NAD Posted February 12, 2013 Share Posted February 12, 2013 function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) end timerjTimer = setTimer ( function ( plr ) time = tostring ( time ) - 70 m, s, cs = msToTimeStr ( time ) fullTime = m..":"..s textItemSetText ( timer, "Time Left : "..tostring ( fullTime ) ) if plr then setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", time ) end if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) end end , 50 , 0 , plr ) end end if not Working, Put your Full Code ! Link to comment
Anderl Posted February 12, 2013 Share Posted February 12, 2013 function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) end timerjTimer = setTimer ( function ( plr ) time = tostring ( time ) - 70 m, s, cs = msToTimeStr ( time ) fullTime = m..":"..s textItemSetText ( timer, "Time Left : "..tostring ( fullTime ) ) if plr then setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", time ) end if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) end end , 50 , 0 , plr ) end end if not Working, Put your Full Code ! Learn what tostring is for. Link to comment
3NAD Posted February 12, 2013 Share Posted February 12, 2013 http://www.lua.org/manual/5.1/manual.html#pdf-tostring Link to comment
Anderl Posted February 12, 2013 Share Posted February 12, 2013 I didn't ask you for any manual, I'm telling YOU to learn what is tostring used for. Link to comment
3NAD Posted February 12, 2013 Share Posted February 12, 2013 Hmm.. I guess he get any values ( text or number ) and Convert it to string. Link to comment
Anderl Posted February 12, 2013 Share Posted February 12, 2013 So, why are you converting something to a string and then trying to do an arithmetic calculation with it? Link to comment
3NAD Posted February 12, 2013 Share Posted February 12, 2013 Because, I got like this problem and fixed it by ' tostring ' Definition ! Link to comment
Anderl Posted February 12, 2013 Share Posted February 12, 2013 Just because the error is the same doesn't mean the cause of it is too. You can't do calculations with strings. Link to comment
MR.S3D Posted February 12, 2013 Share Posted February 12, 2013 Just because the error is the same doesn't mean the cause of it is too. You can't do calculations with strings. + 1 Link to comment
3NAD Posted February 12, 2013 Share Posted February 12, 2013 So, I can't test the Code without full informations . If my Code was Fault, Just put Full Code !! I have a petty question : - Why you are Angry of me ? looool !! Link to comment
Anderl Posted February 12, 2013 Share Posted February 12, 2013 So, I can't test the Code without full informations . If my Code was Fault, Just put Full Code !! I have a petty question : - Why you are Angry of me ? looool !! I'm not angry, I'm just telling you the truth. I'm sorry if it sounded rude. Link to comment
K4stic Posted February 12, 2013 Author Share Posted February 12, 2013 Trollolol i only ask help nothing else if you thing tosring not will work post code that who you think will work i will test the script then i will have 2 players Link to comment
MR.S3D Posted February 12, 2013 Share Posted February 12, 2013 if this does not work then show me full code try with this function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) timerjTimer = nil end timerjTimer = setTimer ( function ( plr ) if isElement(plr) then local timee = tonumber ( time or 0 ) - 70 m, s, cs = msToTimeStr ( timee ) fullTime = ''..tostring(m)..':'..tostring(s)..'' textItemSetText ( timer, "Time Left : "..fullTime ) setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", timee ) if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) end end end , 50 , 0 , plr ) end end Link to comment
TAPL Posted February 12, 2013 Share Posted February 12, 2013 function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) timerjTimer = nil end timerjTimer = setTimer ( function ( plr, timer, time ) if isElement(plr) then local timee = tonumber ( time or 0 ) - 70 m, s, cs = msToTimeStr ( timee ) fullTime = ''..tostring(m)..':'..tostring(s)..'' textItemSetText ( timer, "Time Left : "..fullTime ) setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", timee ) if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) end end end , 50 , 0 , plr, timer, time ) end end Link to comment
K4stic Posted February 22, 2013 Author Share Posted February 22, 2013 make x100 outputChatBox messages with this code -.- Link to comment
TAPL Posted February 22, 2013 Share Posted February 22, 2013 Is there anyone saw a thing called "outputChatBox" runaway from the justice in this topic? Link to comment
K4stic Posted February 22, 2013 Author Share Posted February 22, 2013 -.- just then i use the old code it wos normal then i put your is make the chatbox crazy -.- Link to comment
gokalpfirat Posted February 22, 2013 Share Posted February 22, 2013 -.- just then i use the old code it wos normal then i put your is make the chatbox crazy -.- There arent any output thing you want to day debug string? Link to comment
TAPL Posted February 23, 2013 Share Posted February 23, 2013 Try this function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) timerjTimer = nil end timerjTimer = setTimer ( function ( plr, timer, time ) if isElement(plr) then local timee = tonumber ( time or 0 ) - 70 m, s, cs = msToTimeStr ( timee ) fullTime = ''..tostring(m)..':'..tostring(s)..'' textItemSetText ( timer, "Time Left : "..fullTime ) setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", timee ) if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) timerjTimer = nil end end end end , 50 , 0 , plr, timer, time ) end end if didn't work, post full code, include the function onTimerFinish. Link to comment
K4stic Posted February 23, 2013 Author Share Posted February 23, 2013 now the timer just stuck -.- Link to comment
K4stic Posted February 23, 2013 Author Share Posted February 23, 2013 Command = get("command") -- getTheCommand function getData(to) local file = xmlLoadFile("data.xml") jTable = {} tTable = {} if file then for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"Jails",0)))do local name = xmlNodeGetAttribute(v,"name") local posX,posY,posZ = xmlNodeGetAttribute(v,"posX"),xmlNodeGetAttribute(v,"posY"),xmlNodeGetAttribute(v,"posZ") local int = xmlNodeGetAttribute(v,"int") local dim = xmlNodeGetAttribute(v,"dim") table.insert(jTable, {name,posX,posY,posZ,int,dim}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"time",0)))do local times = xmlNodeGetAttribute(v,"times") for i =1,50 do local iTime = gettok ( times, i, string.byte(',') ) if iTime then -- if tonumber(iTime) > 59.5 then iTime = math.floor(iTime / 60) iTimeDes = "Minutes" if iTime > 59.5 then iTime = math.floor(iTime / 60) iTimeDes = "Hours" end else iTimeDes = "Seconds" end table.insert(tTable,{iTime,iTimeDes}) end end end end triggerClientEvent(to,"sendDataz",to,jTable,tTable) -- sending to client event end addEvent("getDataz",true) addEventHandler("getDataz",root,getData) addCommandHandler ( Command, -- Adding The Command Handler function ( player, cmd ) if hasObjectPermissionTo ( player, "command.kick" ) then triggerClientEvent(player,"jailShow",player) else outputChatBox(" Access Denied ",player,255,0,0) end end ) function removeVehicle(thePlayer) if isPedInVehicle(thePlayer) then destroyElement(getPedOccupiedVehicle(thePlayer)) end end function JailHim(jailed,theJails,time,timeDes,showWho,timeReady) thePlayer = getPlayerFromName(jailed) if not thePlayer then outputChatBox("#FFFF00Please Select a Player !",source,255,0,0,true) return end removePedFromVehicle(thePlayer) for k,v in ipairs ( jTable ) do if theJails == v[1] then theJail = v end end if theJail then if tostring(time) then if timeReady == true then theTimex = tonumber(time) else theTimex = gettok ( time, 1, string.byte(timeDes) ) end if timeDes == "Hours" then theTimex = math.floor(theTimex*60*60*1000) elseif timeDes == "Minutes" then theTimex = math.floor(theTimex*60*1000) elseif timeDes == "Seconds" then theTimex = math.floor(theTimex*1000) end startJailTimer ( thePlayer , theTimex ) local x,y,z = theJail[2],theJail[3],theJail[4] local int = theJail[5] local dim = theJail[6] setElementInterior ( thePlayer, int ) setElementDimension ( thePlayer, dim ) setElementPosition (thePlayer,x,y,z ) setElementData(thePlayer,"isjailed",true) setElementData(thePlayer,""..getPlayerSerial(thePlayer).."-j",true) toggleControl(thePlayer,"fire",false) if showWho ~= true then outputChatBox("#FFFF00You Jailed [ "..getPlayerName(thePlayer).." #FFFF00] at "..theJail[1].." For "..time,source,255,0,0,true) outputChatBox("#FFFF00You Have Been Jailed By "..getPlayerName(source).." #FFFF00 at "..theJail[1].." For "..time,thePlayer,255,0,0,true) end outputChatBox(""..getPlayerName(thePlayer).." #FF0000 Has Been Jailed For "..time.." for beaking rule",root,255,0,0,true) else outputChatBox("#FFFF00Please Select Time !",source,255,0,0,true) end else outputChatBox("#FFFF00Please Select a Jail !",source,255,0,0,true) end end addEvent("JailHimx",true) addEventHandler("JailHimx",root,JailHim) function unJailHim(jailed,showWho) thePlayer = getPlayerFromName(jailed) if not thePlayer then outputChatBox("#FFFF00Please Select a Player !",source,255,0,0,true) return end if getElementData(thePlayer,"isjailed") == true then setElementInterior ( thePlayer, 0) setElementDimension ( thePlayer, 0 ) setElementPosition ( thePlayer, 1552.9108886719, -1675.5844726563, 16.1953125) setElementData(thePlayer,"isjailed",false) setElementData(thePlayer,""..getPlayerSerial(thePlayer).."-j",false) if showWho ~= true then outputChatBox("#FFFF00You Released "..getPlayerName(thePlayer).." #FFFF00",source,255,0,0,true) outputChatBox("You Have Been Released by "..getPlayerName(source).."",thePlayer,255,0,0,true) end outputChatBox(""..getPlayerName(thePlayer).." #FF0000 Has Been Released ",root,255,0,0,true) stopJailTimer(Player) setPlayerWantedLevel ( thePlayer, 0 ) toggleControl(thePlayer,"fire",true) else outputChatBox("The Player is Not Jailed !",source,255,0,0,true) end end addEvent("unJailHim",true)-- unJail addEventHandler("unJailHim",root,unJailHim) addEvent("onJailEnd",true) addEventHandler("onJailEnd",root,function(player) unJailHim(getPlayerName(player),true) end ) addEventHandler("onPlayerSpawn",root, -- Check If He Is Jailed [ OnSpawn ] function() if getElementData(source,"isjailed") == true then randomJail = jTable[math.random(#jTable)] if randomJail then x,y,z = randomJail[2],randomJail[3],randomJail[4] int = randomJail[5] dim = randomJail[6] setElementInterior ( source, int ) setElementDimension(source,dim) setElementPosition (source,x,y,z ) end end end) addEventHandler("onPlayerJoin",root, -- Check If He Is Jailed - By Serial [ OnJoin ] function() if getElementData(getResourceRootElement(getThisResource()),""..getPlayerSerial(source).."-j") == true then randomJail = jTable[math.random(#jTable)] if randomJail then x,y,z = randomJail[2],randomJail[3],randomJail[4] int = randomJail[5] dim = randomJail[6] setElementInterior (source, int) setElementDimension(source,dim) setElementPosition (source,x,y,z ) -- time = getElementData( source,""..getPlayerSerial(source).."-t",time) or 5 * 1000 startJailTimer(source,time) setElementData(source,"isjailed",true) end end end ) ---- function startJailTimer(Player,theTime) -- to start mission timer .. if Player then TimerDisplay = textCreateDisplay() m,s,cs = msToTimeStr(theTime) fullTime = ''..tostring(m)..':'..tostring(s)..'' TimerText = textCreateTextItem ( "Time Left : "..tostring(fullTime).."", 0.39, 0.7 ,"medium",0,255,0,255,2.0,"left","center",255) textDisplayAddText ( TimerDisplay, TimerText ) textDisplayAddObserver ( TimerDisplay, Player ) sortTimerj(Player,TimerText,theTime) end end --taken from JailTimerr resource function msToTimeStr(ms) if not ms then return '' end if ms < 0 then return "0","00","00" end local centiseconds = tostring(math.floor(math.fmod(ms, 1000)/10)) if #centiseconds == 1 then centiseconds = '0' .. centiseconds end local s = math.floor(ms / 1000) local seconds = tostring(math.fmod(s, 60)) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring(math.floor(s / 60)) return minutes, seconds, centiseconds end function sortTimerj ( plr, timer, time ) if timer and time then if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) end timerjTimer = setTimer ( function ( plr ) time = tonumber ( time or 0 ) - 70 m, s, cs = msToTimeStr ( time ) fullTime = ''..tostring(m)..':'..tostring(s)..'' textItemSetText ( timer, "Time Left : "..tostring ( fullTime ) ) if plr then setElementData ( resourceRoot, getPlayerSerial ( plr ).. "-t", time ) end if ( tonumber ( m ) <= 0 and tonumber ( s ) <= 0 and tonumber ( cs ) <= 0 ) then onTimerFinish(plr,timer) if isTimer ( timerjTimer ) then killTimer ( timerjTimer ) timerjTimer = nil end end end , 50 , 0 , plr ) end end function stopJailTimer(Player) textDestroyDisplay(TimerDisplay) if TimerText then textDestroyTextItem(TimerText) end if isTimer(timerjTimer) then killTimer(timerjTimer) end end function onTimerFinish(Player) -- on timer end stopJailTimer(Player) triggerEvent("onJailEnd",Player,Player) end full code i fix the stuck timer but then player jailed and them reconnect the timer lost and error at line 218 says Boolean value and if i jail 1 player and them i jail and second player the first player have timer bug Link to comment
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