Postado Abril 29, 2017 8 anos Boa noite, eu tinha um script na versão 8.6 perfeitamente funcionando, fui passa-lo para a versão 11 e estou enfrentando problemas, O que acontece é o seguinte, a função AddEvent no tfs 1.2 não deixa você jogar uma variavel no AddEvent que pode não existir quando a função for executada.. E meu script joga isso e eu não sei resolver.. SCRIPT: Citar local t = { main = { tfs_version = "0.3", --0.3 or 0.4 positions = { paintball_spawn_area = { top_left = {x = 843, y = 1371, z = 7}, --Top left pos of spawning area bottom_right = {x = 927, y = 1432, z = 7}--bottom right pos of spawning area }, waiting_room_area = { top_left = {x = 927, y = 1398, z = 7}, --Top left pos of the waiting room bottom_right = {x = 938, y = 1409, z = 7}--bottom right pos of the waiting room }, tp_to_paintball = {x = 32613, y = 32661, z = 7}, --pos where the tp will be created event_ending_pos = {x = 32616, y = 32667, z = 7} --pos players will be sent after event ending }, storages = { exhaust = 2353, is_in_event = 2460, score = 2465 }, misc = { status = 'on' }, messages = { event_started = "O evento SnowBall Foi iniciado, entre no teleport no templo para participar, tempo de espera: 3 minutos!",--Message that will be broadcasted after the event has started event_ended = "O evento SnowBall Acabou!" --same but when event ends }, event_config = { event_duration = 8, --minutes, 0 if it's an always-open event infinite_ammo = false, winner_gets_item = true, prize_item_id = 10559, prize_item_id2 = 9734, prize_item_id3 = 2160, prize_item_id4 = 12544, decrease_score_on_death = true, points_per_kill = 1, randomize_player_start_pos = true, ammo_per_point = 5, reset_bullets_on_death = true, min_bullets_on_spawn = 30, start_automatically = true, use_waiting_room = true, waiting_time = 3 --minutes } }, onShoot = { storages = { ammo = 1294 }, misc = { walls_id = {7000,6762,6722,6719,6723,6720,6761,6721,7021,2697,1354,7023,7022,7020,7008,7009,7010,7011,8642,2698,1115,1111,1112,5258,1385,1113}, bullets_exhaust = 500, --in ms bullet_speed = 150 }, vars = { shootdir = 0 } } } function onSay(cid, words, param) if getPlayerStorageValue(cid, t.main.storages.exhaust) <= 1 then if(getPlayerItemCount(cid, t.onShoot.storages.ammo) > 0) then if t.main.misc.status == 'on' then if(t.main.event_config.infinite_ammo == false) then doPlayerRemoveItem(cid, t.onShoot.storages.ammo,1) end setPlayerStorageValue(cid, t.main.storages.exhaust, 2) lineAnimation1(getPlayerLookDir(cid),getCreaturePosition(cid),9,cid,1,0,1,0,0,0,1,0) addEvent(setPlayerStorageValue,t.onShoot.misc.bullets_exhaust, cid:getId(), t.main.storages.exhaust,1) else return false end else doPlayerSendCancel(cid, "Suas PEDRAS acabaram.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) end else doPlayerSendCancel(cid, "Cooldown") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) end return true end function lineAnimation1(lookDir, playerPos, effect, cid, fvar, fpos, ffound, fposV, fcheck, fvcid, floopCounter, fvpid, name) local var = fvar local pos = fpos local found = ffound local posV = fposV local check = fcheck local vcid = fvcid local loopCounter = floopCounter local vpid = fvpid local storage = t.main.storages.exhaust if var < 2 then vcid = cid end pos = playerPos if not isInWallArray(convert(lookDir,pos)) then--isInWallArray({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z}) then --isInArray(t.onShoot.misc.walls_id, getThingfromPos({x=convert(lookDir,pos).x, y=convert(lookDir,pos).y,z=convert(lookDir,pos).z, stackpos=0}).itemid) then doSendDistanceShoot(pos, convert(lookDir,pos),effect) pos = convert(lookDir,pos) var=var+1 posV = convertV(lookDir,playerPos) for _, pid in ipairs(getOnlinePlayers()) do if (getCreaturePosition(pid).x == pos.x and getCreaturePosition(pid).y == pos.y and getCreaturePosition(pid).z == pos.z) then --if loopCounter > 2 then vpid = pid --end if (vpid ~= vcid) then if var > 2 then if (getCreaturePosition(pid).x == posV.x and getCreaturePosition(pid).y == posV.y and getCreaturePosition(pid).z == posV.z) then doTargetCombatHealth( vcid, pid, COMBAT_PHYSICALDAMAGE, -20, -20) doCreatureAddHealth(vcid, 10) if (lookDir == 0) or (lookDir == 2) then var = 6 else var = 8 end end end doTargetCombatHealth( vcid, pid, COMBAT_PHYSICALDAMAGE, -20, -20) doCreatureAddHealth(vcid, 10) if (lookDir == 0) or (lookDir == 2) then var = 6 else var = 8 end end end loopCounter = loopCounter +1 end if (lookDir == 0) or (lookDir == 2) then if var ~= 6 then vcid:getId() addEvent(lineAnimation1, t.onShoot.misc.bullet_speed, lookDir, pos, effect, nil, var, pos, found, posV, check, vcid, loopCounter, vpid) else var = 1 end else if var ~= 8 then addEvent(lineAnimation1, t.onShoot.misc.bullet_speed, lookDir, pos, effect, nil, var, pos, found, posV, check, vcid, loopCounter, vpid) else var = 1 end end else doSendMagicEffect(convert(lookDir,pos),2) var = 1 end end local ret = {} function convert(lookDir,pos) local positions = { [0] = {x = pos.x, y = pos.y-1, z = pos.z}, [1] = {x = pos.x+1, y = pos.y, z = pos.z}, [2] = {x = pos.x, y = pos.y+1, z = pos.z}, [3] = {x = pos.x-1, y = pos.y, z = pos.z} } ret = positions[lookDir] return ret end local ret = {} function convertV(lookDir,pos) local positions = { [0] = {x = pos.x, y = pos.y+1, z = pos.z}, [1] = {x = pos.x-1, y = pos.y, z = pos.z}, [2] = {x = pos.x, y = pos.y-1, z = pos.z}, [3] = {x = pos.x+1, y = pos.y, z = pos.z} } ret = positions[lookDir] return ret end function isInWallArray(pos) for k = 0, table.getn(t.onShoot.misc.walls_id) do if getTileItemById(pos, t.onShoot.misc.walls_id[k]).itemid == t.onShoot.misc.walls_id[k] then --this doesn't even make sense but tried other ways and it gave errors, so meh 2lazy2search return true end end return false end Citar Lua Script Error: [TalkAction Interface] data/talkactions/scripts/SHOT1.lua:onSay LuaScriptInterface::luaAddEvent(). Argument #12 is unsafe stack traceback: [C]: in function 'addEvent' data/talkactions/scripts/SHOT1.lua:158: in function 'lineAnimation1' data/talkactions/scripts/SHOT1.lua:72: in function <data/talkactions/scripts/SHOT1.lua:63> Bom, grifei em vermelho a linha que da o erro e em verde o que provoca o erro.. OBS¹: O Script funciona perfeitamente, porém com o erro ai...
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.