Jump to content

Problem to save garagen


Eistee

Recommended Posts

Hello, i have a problem with my garagen script.

The Owner of the garage will not be saved, when a admin add the garage to a player..

local mieter = {  
    [1]="NoName", 
    [2]="blaa", 
    [3]="MRdonaut", 
    [4]="false", 
    [5]="false", 
    [6]="NoName", 
    [7]="NoName", 
    [8]="NoName", 
    [9]="NoName", 
    [10]="NoName", 
    [11]="Bright" 
  
} 

for i = 1, #preis, 1 do 
    preis[i] = gettok(preis[i], 1, ",") 
end 
  
for i = 1, #mieter, 1 do 
    mieter[i] = gettok(mieter[i], 1, ",") 
end 
  
for i = 1, #state, 1 do 
    state[i] = gettok(state[i], 1, ",") 
end 
  
  
  
function adminAddOwner( thePlayer, cmd, garage, nmieter) 
     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    table.insert (mieter, garage, nmieter) 
    outputChatBox("Du hast die Gerage : "..garage.." zum eigentum von : "..nmieter.." hinzugefügt", thePlayer, 0, 200, 0, false) 
    else 
    outputChatBox("Du hast nicht Genug Rechte Dafür !", thePlayer, 0, 200, 0, false)        
    end 
end 
addCommandHandler("garage", adminAddOwner) 

Link to comment

I would not use tables for such data, and the code should work (perhaps you're using ACL groups but you have another kind of administration system?). I also recommend you doing an assignment instead of using the table.insert function, it's faster:

if ( garage and nmieter ) then 
    mieter[ garage ] = tostring ( nmieter ); 
end 

Link to comment

Here;

local mieter = {  
    [1]="NoName", 
    [2]="blaa", 
    [3]="MRdonaut", 
    [4]="false", 
    [5]="false", 
    [6]="NoName", 
    [7]="NoName", 
    [8]="NoName", 
    [9]="NoName", 
    [10]="NoName", 
    [11]="Bright" 
  
  
  
  
} 

Link to comment
function adminAddOwner( thePlayer, cmd, garage, nmieter) 
     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    table.insert (mieter, garage, nmieter) 
    outputChatBox("The garage : "..garage.." added to the player : "..nmieter.."", thePlayer, 0, 200, 0, false) 
    else 
    outputChatBox("No rights !", thePlayer, 0, 200, 0, false)        
    end 
end 
addCommandHandler("garage", adminAddOwner) 

Link to comment
local gerage = { --Hier Geragen eintragen in Format [iD]="id, x, y, z, rotx, roty, roz, movetox, movetoy, movetoz, movetorotx, movetoroty, movetorotz, time", 
    [1]="7891, -2506.69921875, 761, 36, 0, 0, 0, -2506.69921875, 761.099609375, 38, 0, -90, 0, 2000", 
    [2]="7891, -2506.69921875, 768.5, 36, 0, 0, 0, -2506.69921875, 768.099609375, 38, 0, -90, 0, 2000", 
    [3]="7891, -2506.69921875, 775, 36, 0, 0, 0, -2506.69921875, 775.099609375, 38, 0, -90, 0, 2000", 
    [4]="7891, -2016.7487792969, 405.73351074219, 36, 0, 0, 0, -2016.7487792969, 405.73351074219, 38, 0, -90, 0, 2000", 
    [5]="7891, -2016.7487792969, 416.51150463867, 36, 0, 0, 0, -2016.7487792969, 415.61150463867, 38, 0, -90, 0, 2000", 
    [6]="7891, -2016.7487792969, 427.51151123047, 36, 0, 0, 0, -2016.7487792969, 427.51151123047, 38, 0, -90, 0, 2000", 
    [7]="7891, -1991.3994140625, 389.599609375, 36, 0, 0, 0, -1991.3994140625, 389.599609375, 38, 0, 90, 0, 2000", 
    [8]="7891, -1991.5, 378.33990478516, 36, 0, 0, 0, -1991.5, 378.33990478516, 38, 0, 90, 0, 2000", 
    [9]="7891, -1921.3994140625, 300, 42.299999237061, 0, 0, 270, -1921.3994140625, 300, 44.299999237061, 0, 90, 270, 2000", 
    [10]="7891, -1913.3994140625, 300, 42.299999237061, 0, 0, 270,  -1913.3994140625, 300, 44.299999237061, 0, 90, 270, 2000", 
    [11]="7891, -1991.5, 367.39999389648, 36, 0, 0, 0, -1991.5, 367.39999389648, 38, 0, 90, 0, 2000" 
    -- Standart Garagen ID 17950 
--Muss in Format sein : [iD Der Garage]="ID Des Objektes f??aragen Tor 7891, x Kordinate, Y Kordinate, y Kordinate, x Rotation, Y Rotation ,Z Rotation, Zu Moven X, Zu Y, Zu Z, Zz XRot, zu Y Rot, Zu Z rot, Zeit die Bewegung", 
} 
  
  
local state = { --Hier Geragen eintragen in Format [iD]="False", 
    [1]="false", 
    [2]="false", 
    [3]="false", 
    [4]="false", 
    [5]="false",     
    [6]="false", 
    [7]="false", 
    [8]="false", 
    [9]="false", 
    [10]="false", 
    [11]="false" 
     
} 
  
local mieter = { --Hier Geragen eintragen in Format [iD]="NameDesMieters", 
--wenn -- Vor dem Namen ist gehört sie Niemanden und der Preis wird Dar gestelt 
    [1]="NoName", 
    [2]="blaa", 
    [3]="MRdonaut", 
    [4]="false", 
    [5]="false", 
    [6]="NoName", 
    [7]="NoName", 
    [8]="NoName", 
    [9]="NoName", 
    [10]="NoName", 
    [11]="Bright" 
  
  
  
-- Wenn Kaufbar dann -- Vor Garagen ID 
} 
  
  
local preis = { --Hier Geragen eintragen in Format [iD]="NameDesMieters", 
    [1]="870.000", 
    [2]="870.000", 
    [3]="870.0000", 
    [4]="870.0000", 
    [5]="870.0000", 
    [6]="870.0000", 
    [7]="870.0000", 
    [8]="870.0000", 
    [9]="870.0000", 
    [10]="870.0000", 
    [11]="870.0000" 
--Garagen Preise! Müßen Da Sein! 
} 
  
--Table Zuordnung NICHTS ÄNDERN 
  
for i = 1, #preis, 1 do 
    preis[i] = gettok(preis[i], 1, ",") 
end 
  
for i = 1, #mieter, 1 do 
    mieter[i] = gettok(mieter[i], 1, ",") 
end 
  
for i = 1, #state, 1 do 
    state[i] = gettok(state[i], 1, ",") 
end 
  
  
  
function adminAddOwner( thePlayer, cmd, garage, nmieter) 
     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    table.insert (mieter, garage, nmieter) 
    outputChatBox("Du hast die Gerage : "..garage.." zum eigentum von : "..nmieter.." hinzugefügt", thePlayer, 0, 200, 0, false) 
    else 
    outputChatBox("Du hast nicht Genug Rechte Dafür !", thePlayer, 0, 200, 0, false)        
    end 
end 
addCommandHandler("garage", adminAddOwner) 
  
  
for i = 1, #gerage, 1 do 
    local id, x, y, z, rotx, roty, rotz, nx, ny, nz, nrotx, nroty, nrotz, time = gettok(gerage[i], 1, ","), gettok(gerage[i], 2, ","), gettok(gerage[i], 3, ","), gettok(gerage[i], 4, ","), gettok(gerage[i], 5, ","), gettok(gerage[i], 6, ","), gettok(gerage[i], 7, ","), gettok(gerage[i], 8, ","), gettok(gerage[i], 9, ","), gettok(gerage[i], 10, ","), gettok(gerage[i], 11, ","), gettok(gerage[i], 12, ","), gettok(gerage[i], 13, ","), gettok(gerage[i], 14, ",") 
    gerage[i] = createObject(id, x, y, z, rotx, roty, rotz) 
    --setObjectScale ( gerage[i], 0.87 ) 
    addEventHandler("onElementClicked", gerage[i], 
        function(but, stat, thePlayer) 
            if(but == "left") and (stat == "down") then 
            local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
            if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
            outputChatBox("ID : "..i.."", thePlayer, 0, 200, 0, false ) 
            end 
                local x1, y1, z1 = getElementPosition(thePlayer) 
                if(getDistanceBetweenPoints3D(x1, y1, z1, x, y, z) > 10) then return end 
                    if (getPlayerName(thePlayer) == mieter[i]) or (mieter[i] == "false") then 
                        if (mieter[i] == "false") then 
                            outputChatBox("Diese Garage gehört niemanden, du kannst sie für "..preis[i].." $ kaufen!", thePlayer, 0, 200, 0, false) 
                        else 
                            if (state[i] == false) then 
                                state[i] = true 
                                moveObject(gerage[i], time, x, y, z, rotx, roty, rotz, "OutQuad" ) 
                                outputDebugString(getPlayerName(thePlayer).." Hat eine Garage zugemacht") 
                                if (i >= 1) then  
                                    moveObject(gerage[i], time, x, y, z, rotx, 90, rotz, "OutQuad" ) 
                                end 
                            else 
                                state[i] = false 
                                moveObject(gerage[i], time, nx, ny, nz, nrotx, nroty, nrotz, "OutQuad") 
                                outputDebugString(getPlayerName(thePlayer).." Hat eine Garage aufgemacht") 
                                if not (state[i] == true) then 
                                    setTimer(moveObject, 120000, 1, gerage[i], time, x, y, z, rotx, roty, rotz, "OutQuad") 
                                    setTimer(outputDebugString, 120000, 1, "Die Garage von : "..getPlayerName(thePlayer).." Wurde in 5 Minuten Geschlossen") 
                                end 
                            end 
                        end 
                    else 
                outputChatBox("Diese Garage gehoert dir nicht! Der aktuelle Mieter ist: "..mieter[i].."!", thePlayer, 0, 200, 0, false) 
            end 
        end 
    end) 
end 

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