Chlorek Posted June 18, 2011 Share Posted June 18, 2011 Hi. I scripted clue script and while I was testing script I found one stupid error. Server side code: addEvent("checkClue", true) function cluetimer() if(pickupClue)then outputChatBox("Too slow! Old clue destroyed!", 255, 255, 0) destroyElement(pickupClue) else local clue = math.random(0,2) if (clue == 0) then pickupClue = createPickup (-1455.66,-102.42,6.00, 3, 1279) treasure = "I am underground in section E and near EXIT door!" outputChatBox("CLUE: " .. treasure, getRootElement(), 255, 255, 0) elseif(clue == 1) then treasure = "I have to wait for the train." pickupClue = createPickup (-1968.72,111.20,27.69, 3, 1279) outputChatBox("CLUE: " .. treasure, getRootElement(), 255, 255, 0) elseif(clue == 2) then treasure = "Mount Chiliad!" pickupClue = createPickup (-1996.9760742188,-1563.7082519531,85.77880859375, 3, 1279) outputChatBox("CLUE: " .. treasure, getRootElement(), 255, 255, 0) end end end setTimer(cluetimer, 60000 , 0) function takeclue(takeplayer) if(source == pickupClue)then --cancelEvent() destroyElement(pickupClue) local moneyclue = math.random(1000,80000) givePlayerMoney (takeplayer, moneyclue) local playerName = getPlayerName(takeplayer) treasure = "Clue will be placed soon!" outputChatBox ("You got the clue and have earned $" .. moneyclue .. "!", takeplayer, 0, 255, 0) outputChatBox (playerName .. " found the clue and earned $" .. moneyclue .. "!", 255, 255, 0) outputChatBox ("The next clue will be placed for 10 minutes!", 255, 255, 0) end end addEventHandler ("onPickupUse", getRootElement(), takeclue) function checkClue() if not (pickupClue) then outputChatBox("CLUE: Clue will be placed soon!", source, 255, 255, 0) else local sendTreasure = tostring(treasure) outputChatBox("CLUE: " .. treasure, source, 255, 255, 0) end end addEventHandler ("checkClue", getRootElement(), checkClue) On the client side is command handler only (not important). So when I pick up pack I get money etc... but when timer run function cluetimer again it DETECT pickupClue element is created and I don't know why. My script should destroy pickup at 28th line! All other "if's" detect it is detroyed. Please help and thanks! Link to comment
DarkLink Posted June 18, 2011 Share Posted June 18, 2011 I dont know for sure.. but when u put and if, and u next use an elseif u have to put an end before the else if.. like this: [lua] if (clue == 0) then pickupClue = createPickup (-1455.66,-102.42,6.00, 3, 1279) treasure = "I am underground in section E and near EXIT door!" outputChatBox("CLUE: " .. treasure, getRootElement(), 255, 255, 0) end elseif(clue == 1) then ... ... try it bro Link to comment
Chlorek Posted June 18, 2011 Author Share Posted June 18, 2011 oh no... It's not problem DarkLink =] but thanks for trying to help. PS. end is using after all if, elseif, else (one only). Link to comment
DarkLink Posted June 18, 2011 Share Posted June 18, 2011 Hm sorry And which error gives on console? Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 Post the error, and post the line. Link to comment
Chlorek Posted June 18, 2011 Author Share Posted June 18, 2011 and this is problem. i am on mobile and i cant post error but i member it is problem at 5th line and it is couldnt destroy element (bcuz of it is destroyed). function if should detect it is destroyed but it doesnt. Link to comment
DarkLink Posted June 18, 2011 Share Posted June 18, 2011 and this is problem. i am on mobile and i cant post error but i member it is problem at 5th line and it is couldnt destroy element (bcuz of it is destroyed). function if should detect it is destroyed but it doesnt. bro do this if (isElement(pickupClue) then destroyElement(pickupClue) else outputChatBox("The Element can't be destroyed") end Link to comment
Chlorek Posted June 18, 2011 Author Share Posted June 18, 2011 Oh thanks for help DarkLink! It works! I forgot about use isElement but still I don't understand why in other functions it worked 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