-- Create Peds.xml and insert tags --
function createFileHandler ( )
local file = xmlCreateFile ( "peds/peds.xml", "peds" )
xmlSaveFile ( file )
end
addCommandHandler ( "addpedfile", createFileHandler )
function pedfunc ( player, cmd, id )
if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( player ) ), aclGetGroup ( "lvl 5" ) ) then
if ( id == "" ) then
outputChatBox ( "Ped-System: Error, the command is /addped ", player, 255, 0, 0 )
return
end
local x, y, z = getElementPosition ( player )
local rot = getPedRotation ( player )
local int = getElementInterior ( player )
local dim = getElementDimension ( player )
local file = xmlLoadFile ( "peds/peds.xml" )
if ( file ) then
local newChild = xmlFindChild ( file, "peds", 0 )
xmlNodeSetAttribute ( newChild, "id", id )
xmlNodeSetAttribute ( newChild, "x", x )
xmlNodeSetAttribute ( newChild, "x", x )
xmlNodeSetAttribute ( newChild, "y", y )
xmlNodeSetAttribute ( newChild, "z", z )
xmlNodeSetAttribute ( newChild, "rotation", rot )
xmlNodeSetAttribute ( newChild, "int", int )
xmlNodeSetAttribute ( newChild, "dim", dim )
xmlSaveFile ( file )
created = createPed ( id, x+1, y, z, rot, int, dim )
setElementInterior ( created, int )
setElementDimension ( created, dim )
setPedRotation ( created, rot )
setElementFrozen ( created, true )
outputChatBox ( "Ped-System: You have successfully made a ped with an ID of #ff0000".. id .."#00ff00!", player, 0, 255, 0, true )
else
outputChatBox ( "Ped-System: Failed to load XML file!", player, 255, 0, 0 )
end
else
outputChatBox ( "Ped-System: This command is only for admins!", player, 255, 0, 0 )
end
end
addCommandHandler ( "addped", pedfunc )
xmlSaveFile was missing.