Jump to content

zixxonx

Members
  • Posts

    57
  • Joined

  • Last visited

Posts posted by zixxonx

  1. Looks like it partially works. Now I wanted to make it that If a vehicle is in cuboid it adds +1 to the variable but it counts all the cars I have on the server

    So if I have 5 cuboids for 5 parking places

    cuboid[1]

    cuboid[2]

    cuboid[3]

    cuboid[4]

    cuboid[5]

    And i have something like it:

      
    (at top of the script) count = 0 
    local vehicles = getElementsByType("vehicle") 
    for k,v in ipairs(vehicles)do 
    if(isElementWithinColShape(v,cuboid[1]) or isElementWithinColShape(v,cuboid[2]) or 
    isElementWithinColShape(v,cuboid[3]) or isElementWithinColShape(v,cuboid[4]) or 
    isElementWithinColShape(v,cuboid[5])) then 
    count =count +1 
    else 
    createVehicle(foo) 
    end 
    end 
    

    And I spawn first car then count is 1, but when I spawn second count is 2, and... when I'm trying to spawn the third count is 4 because it's add +1 2x to variable.

    It's hard to explain but I want it done so badly. :P

  2. Hello, I have a table with 5 cuboids:

    cuboid[1] = {x,y,z,10,10,10}

    cuboid[2] = {x,y,z,10,10,10}

    etc

    and I wanna check if there is any vehicle on these cuboids, if no then break the table i tried it

      
    for _,v in ipairs(getElementsByType('vehicle')) do 
                outputChatBox('checking from ' .. getVehicleName(v) .. ' perspective') 
                for i=1, 5 do 
                    if isElementWithinColShape(v, cuboid[i]) then 
                        outputChatBox(i .. ' taken by ' .. getVehicleName(v)) 
                    else 
                        outputChatBox(i .. ' free') 
                    end 
                end 
            end 
      
    

    So i spawn 2 cars at 2 cuboids, infernus at 1st, cheetah at 2nd

    checking from Cheetah perspective 
    1 free 
    2 taken by Cheetah 
    3 free 
    4 free 
    5 free 
    checking from Infernus perspective 
    1 taken by Infernus 
    2 free 
    3 free 
    4 free 
    5 free 
    

    the problem is that Cheetah sees that cuboid 1 is free while it's taken and infernus sees 1 is free :(

    Could you help me?

  3. hello i'm just messing with my friend on the server and when he shot my wheel only I could see it's flat, he seen it as normal and when he entered the veh he was driving it like it's all ok, i tested it and really the flat tires arent synced, how can I fix them?

  4. Oh well, thanks. So when i create the table for player

    data[source] = {things here} 
    

    I need to put here all the variables i will be using in future for this table? I mean if i do it like this:

        data[source] = {deaths = 0, kills=0} 
    

    And later on i wanna also add CASH here, it's possible? Or maybe even like in PAWN i could do like this:

    enum UserData

    {

    ID,

    Admin,

    Gender,

    SkinID,

    MaskID

    }

    And later then

    UserData[playerid][skinID] = 666

  5. Hello, i'm really struggling with saving players data in tables. Let's for example, i have that table:

    data = {} 
    

    When player joins i want to set some things for him. I'm doing it by:

    data[source] = {deaths = 0, kills=0} 
    

    Now, when player kills somebody i want to increase his kills.

    kills = data[source].kills + 100 
    data[source] = {kills= kills} 
    

    But this is deleting the DEATHS value from table. How can i achieve it in other way? Thanks.

  6. toilet1 = createElement("toilet", "toilet1") 
    toilet1:setData("times_used", 0) 
    

    Hello! I'm pretty new to OOP in LUA and i have a problem. It's my code.

    But when i run the script it's giving me this error:

    attempt to index global 'toilet1' (a userdata value) 
    

    I really dont know why. Could someone help me? OOP is enabled in mtaserver.cnf

  7. OMG. Forgive me. Foolish mistake. It've should been

    function startRefreshing() 
        setTimer(triggerClientEvent, 1000, 0, "updateClientTable", root, informations) 
    end 
    addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), startRefreshing) 
    

    instead of

        setTimer(triggerClientEvent, 1000, 0, "updateClientTable", root, informations) 
    

  8. Hello! I have problem when using server-sided table on client-side

    Let's take this table as a example:

    informations = { 
       serverPort = 661, 
       players = { } 
    } 
    

    It's server sided. Now i want to pass this table to client-side. I've found something like this:

    setTimer(triggerClientEvent, 1000, 0, "updateClientTable", root, informations)

    It works flawlessy, but. When on client-side i do something like

    informations = {} 
    addEvent ( "updateClientTable", true ) 
    addEventHandler ( "updateClientTable", root, 
        function ( _table) 
            informations = _table 
        outputChatBox(informations.serverPort) 
        end 
    ) 
    

    It shows 661. When i use:

    outputChatBox(#informations.players) to show how much players i've added it shows 0 even if it shows good amount on server side.

    Example server code:

    informations = { 
       serverPort = 661, 
       players = { } 
    } 
    local function addToTable() 
        for i,v in ipairs(getElementsByType('player')) do 
            informations.players[i] = v 
        end 
        outputChatBox('players: '.. #informations.players) 
    end 
    addEvent('onMapStarting', true) 
    addEventHandler ( "onMapStarting", root, addToTable)  
    

    3fZ2PnW.jpg

  9. local px,py,pz = getElementPosition(vehicle)

    local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz )

    if pdistance <= 133 then

    local sx,sy = getScreenFromWorldPosition( px, py, pz + 0.3 )

    if not sx or not sy then break end

    local awatarid = getElementData(player, "omg.avek")

    dxDrawImage(sx-27,sy-55, 55, 64 , 'img/'..awatarid..'.png', 0, 0, 0, tocolor ( 255, 255, 255, 140 ) )

    end

    It works flawlessy but when i'm near to opponent the image is normal, but when im driving out the image is bigger. How can i make it normal-size all the time? Thanks!

  10. Yeah. I got:

    Test: Wybrałeś awatar 1, brawoo!!

    You clicked on: userdata: 00020318

    Test: Wybrałeś awatar 1, brawoo!!

    You clicked on: userdata: 00020314

    Test: Wybrałeś awatar 1, brawoo!!

    You clicked on: userdata: 00020313

    Test: Wybrałeś awatar 1, brawoo!!

    It's ok and i can use it like this

      
    if source == "00020318" then 
    -- code 
    end 
      
    

    ? :) Thanks!

  11. can i check what i've clicked in the?

    for example i got

            GUIEditor.obrazek[1] = guiCreateStaticImage(80,80, 64, 64, "img/1.png", false, GUIEditor.scrollpane[1]) 
            GUIEditor.obrazek[2] = guiCreateStaticImage(150,80, 64, 64, "img/2.png", false, GUIEditor.scrollpane[1]) 
            GUIEditor.obrazek[3] = guiCreateStaticImage(220,80, 64, 64, "img/3.png", false, GUIEditor.scrollpane[1]) 
            GUIEditor.obrazek[4] = guiCreateStaticImage(290,80, 64, 64, "img/4.png", false, GUIEditor.scrollpane[1]) 
            GUIEditor.obrazek[5] = guiCreateStaticImage(80,150, 64, 64, "img/5.png", false, GUIEditor.scrollpane[1]) 
      
            for i = 1, #GUIEditor.obrazek do 
            addEventHandler("onClientGUIClick", GUIEditor.obrazek[i], wybieraAvatar, false) 
            outputChatBox(tostring(i)) 
            end    
    

    then

    function wybieraAvatar() 
            outputChatBox("Test: Wybrałeś awatar 1, brawoo!! ") 
    end 
    

    How can i check what player clicked? Thanks! :)

×
×
  • Create New...