Jump to content

Problem


xeon17

Recommended Posts

I got a problem in my script , i'm tried to create a script who check is the player in event and if he is , then with a command script will take all his weapons..

setElementData ( thePlayer, "Evento" , nil) 

function getWeapons ( thePlayer ) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then    
local players = getElementType ( thePlayer ) == "player" 
for _, events in ipairs(players) do 
local isPlayerInEvento = getElementData( events, "Evento" ) 
if ( isPlayerInEvento) then 
takeAllWeapons (events) 
outputChatBox("#FFF000[EVENTO]#FFFFFF Weapons Deleted !",events, 255, 255, 255, true) 
end 
end 
end 
end 
addCommandHandler ("takeweapons",getWeapons) 

Bug:

[2014-05-28 10:09:53] ERROR: event\iaan.lua:86: bad argument #1 to 'ipairs' (table expected, got boolean) 

Link to comment
function getWeapons ( thePlayer ) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then    
for _, events in ipairs(getElementsByType("player")) do 
local isPlayerInEvento = getElementData( events, "Evento" ) 
if ( isPlayerInEvento) then 
takeAllWeapons (events) 
outputChatBox("#FFF000[EVENTO]#FFFFFF Weapons Deleted !",events, 255, 255, 255, true) 
end 
end 
end 
end 
addCommandHandler ("takeweapons",getWeapons) 

Try that instead.

Link to comment

Nope..

here the full script

on = "nao" 
function event (thePlayer) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then     
if(on == "sim")then 
outputChatBox("#FFF000[sERVER#FFFFFF Evento created, use #FF0000/devent#FFFFFF to close the Event!",thePlayer,255,255,255,true) 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF Administator #FF0000"..getPlayerName(thePlayer).."#FFFFFF created a event, write #FF0000/irevento#FFFFFF to participate!",root,255,255,255,true) 
local x,y,z = getElementPosition(thePlayer) 
coisa = createMarker(x,y,z-1,"cylinder",2,0,255,0) 
dimen =getElementDimension(thePlayer)  
inte = getElementInterior(thePlayer) 
if(inte)then 
setElementInterior(coisa,inte) 
end 
if(dimen)then 
setElementDimension(coisa,dimen) 
end 
on = "sim" 
end 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF You aren't a admin to create a event!",thePlayer,255,255,255,true) 
end 
end 
addCommandHandler("cevent",event) 
function destruir (thePlayer) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then 
if(on == "nao")then 
outputChatBox("#FFF000[sERVER]#FFFFFF There isn't a event, use #FF0000/cevent #FFFFFF to create a event!",thePlayer,255,255,255,true) 
else   
destroyElement(coisa) 
outputChatBox("#FFF000[sERVER]#FFFFFF Administator #FF0000"..getPlayerName(thePlayer).." #FFFFFF Closed the event!",root,255,255,255,true) 
on = "nao" 
end 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF You aren't an admin to destroy a event!",thePlayer,255,255,255,true) 
end 
end 
addCommandHandler("devent",destruir) 
function irevento(thePlayer,cmd) 
takeAllWeapons ( thePlayer ) 
setElementData ( thePlayer, "Evento" , nil) 
setElementHealth ( thePlayer, 100 ) 
setPedArmor ( thePlayer, 100 ) 
local x,y,z = getElementPosition(coisa) 
if(on == "sim")then 
if(getPedOccupiedVehicle (thePlayer))then 
outputChatBox("#FFF000[sERVER]#FFFFFF Leave your vehicle to enter the event",thePlayer,255,255,255,true) 
else 
if(setElementPosition(thePlayer,x,y,z))then 
setElementDimension(thePlayer,getElementDimension(coisa)) 
setElementInterior(thePlayer,inte) 
outputChatBox("#FFF000[sERVER]#FFFFFF Welcome in the Event!",thePlayer,255,255,255,true) 
za,ze,zi = getElementPosition(thePlayer) 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF There isn't a event created!",source,255,255,255,true) 
end 
if(za == x and ze == y and zi == z) then 
setElementPosition(thePlayer,za,ze,zi+1) 
end 
end 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF There isn't a event created!",source,255,255,255,true) 
end 
end 
addCommandHandler("irevento",irevento) 
function Infor(thePlayer) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then   
outputChatBox("#FFF000[sERVER]#FFFFFF  - Commands for Event ",source, 255, 255, 255, true) 
outputChatBox("#FFF000[sERVER]#FFFFFF  #FF0000/cevent#FFFFFF - To create a event [Administators]!",source, 255, 255, 255, true) 
outputChatBox("#FFF000[sERVER]#FFFFFF  #FF0000/devent #FFFFFF- To close the event [Administators]!",source, 255, 255, 255, true) 
outputChatBox("#FFF000[sERVER]#FFFFFF #FF0000/irevento #FFFFFF- To enter the event [Players]!",source, 255, 255, 255, true) 
else 
outputChatBox("#FFF000[sERVER]#FFFFFF You aren't an admin to use this command",source,255,255,255,true) 
end 
end 
addCommandHandler ("event",Infor) 
  
  
function getWeapons ( thePlayer ) 
local accountname = getAccountName (getPlayerAccount(thePlayer)) 
if (isObjectInACLGroup ( "user."..accountname, aclGetGroup ( "Admin" ) )) then   
for _, events in ipairs(getElementsByType("player")) do 
local isPlayerInEvento = getElementData( events, "Evento" , nil ) 
if ( isPlayerInEvento) then 
takeAllWeapons (events) 
outputChatBox("#FFF000[EVENTO]#FFFFFF Weapons Deleted !",events, 255, 255, 255, true) 
end 
end 
end 
end 
addCommandHandler ("takeweapons",getWeapons) 
  

Link to comment
The one who waits for something good never waits too long

Being patient is a good idea, anyway on line 86 in your script you got this:

for _, events in ipairs(getElementsByType("player")) do 

For some reason your script are unable to list the players in your server which seems pretty weird. Are you sure that's the right script?

Link to comment

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