Mojko

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Mojko

  • Rank
    Vic

Details

  • Gang
    Da Nang Boys
  • Location
    Sweden
  • Occupation
    Turfing
  • Interests
    Programming
  1. Thanks everyone for your answers, apparently the problem wasn't a problem at all. pa3ck highlighted a big error I made which I solved, but it wasn't the entire solution. The issue was that I looped too many times, so I looped more times than actual pickups existed. Clarification: I looped 4 times while I only had 2 pickups.
  2. local X, Y, Z, ID, TYPE, PICKUP_ID, DESCRIPTION, COL_ID = 1, 2, 3, 4, 5, 6, 7, 8, 3 --Start of initilizing 2d array local pickupCollision = {} for i = 1, maxPickups do pickupCollision[i] = {} for j = 1, 3 do pickupCollision[i][j] = 0 end end --End of initilizing 2D array
  3. Hi so I have this table with colRectangles that I wanna check collision for. pickupCollision[index][COL_ID] = createColRectangle(x, y, 4, 4) This is how i define the collision rectangles, and now I'm trying to loop through pickupCollision to check collision. This is what I have at the moment: function playerCollisionWithPickup(player, dimension) outputChatBox("player entered the col shape", player) end for i = 1, #pickupCollision do addEventHandler("onColShapeHit", pickupCollision[i][COL_ID], playerCollisionWithPickup) end WARNING: pickupController.lua:93: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil]
  4. Mojko

    bindKey (server)

    Hey I need some help, regarding "bindKey" so what I basicly want to do is check if the player is pressing down a button, and when he does, I want to return a boolean value. function keyInput(player, key, keyState) if(keyState == "down") then end outputChatBox("Pressing: " .. key) end function bindKeysWhenPlayerJoin() bindKey(source, "lalt", "down", keyInput) end addEventHandler("onPlayerJoin", getRootElement(), bindKeysWhenPlayerJoin) So basicly I have the basics down, when the player joins the server the keys will bind, and when I press "lalt" then it gets printed out to the player's chat box. The issue here is though, that I can't use this, for like anything, since I cannot return a value that I can later use. Let me give an example. Psuedo code: I want to check if - The player is colliding with a static pickup - The player is pressing lalt then print a message Code: function playerPickupCollision(pickup, dimension) -- Jobs for i = 1, #pickupInformation do if(pickup == pickupInformation[i][PICKUP_ID]) then outputChatBox(i, source) if(pickupInformation[i][TYPE] == "Job" && pressing_key("lalt")) then outputChatBox("Press LALT to become a " .. pickupInformation[i][DESCRIPTION], source) end if(pickupInformation[i][TYPE] == "Property" && pressing_key("lalt")) then outputChatBox("This is the " .. pickupInformation[i][DESCRIPTION], source) end end end end addEventHandler("onPlayerPickupHit", getRootElement(), playerPickupCollision) (pressing_key isn't an actual function. it's the kind of function I want to create) Thank you!
  5. Yes I do want to check if a turf already exist at the location. and thank you! row["x"] was apparently a string
  6. while true do local row = mysql_fetch_assoc(result) local xx = row["x"] local var_1 = 1 local var_2 = 1 outputChatBox(row["x"]) outputChatBox(turfInformation[1][X]) outputChatBox(row["y"]) outputChatBox(turfInformation[1][Y]) outputChatBox(maxZones) if(row["x"] == turfInformation[1][X]) then outputChatBox("Can't create a turf here") end end So, what do we have here? Basicly I want "Can't create a turf here" be sent as a message to the player if the "X" position in my MySQL table equals to the "X" position of turfInformation. This is what prints out in game at the moment: row["x"] = 2634.71 turfInformation[1][X] = 2634.71 row["y"] = -1649.41 turfInformation[1][Y] = -1649.41 So, what's the issue? "Can't create a turf here" never get's printed out. I've tried to take the value "2634.71" and make an if statement that looks like this: if(turfInformation[1][x] == 2634.71) And that works, but that's not what I want, I want to use row["x"] instead. Thank you! EDIT: Here's the query: local result = mysql_query(connection,"SELECT * FROM gang_territories")