Jump to content

unknooooown

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by unknooooown

  1. Hi. I'm back! Really getting hooked on scripting Lua Well, my new problem is a math.random, problem. When I try to get the value of my randMoney, I ALWAYS get a nil value. I am not sure what I am doing wrong, because of my other math.random works just fine. Anyways.. Here is the script. Hope someone can help me out on this one function drugRunner (thePlayer, command) local randDrugMarker = { {-720,961,12}, {-705,968,12}, {-698,954,12}, {-711,942,12} } local randDrugMoneyGet = math.random(50,500) local randomX, randomY, randomZ = unpack(randDrugMarker[math.random(#randDrugMarker)]) local theDrugMarker = createMarker ( randomX, randomY, randomZ, "cylinder", 1.5, 255, 255, 0, 170 ) local randMoney = unpack(randDrugMoneyGet[math.random(#randDrugMoneyGet)]) end function markerHit ( thePlayer ) if(randMoney) then outputChatBox ("The Number Is:" .. tostring(randMoney)) else outputChatBox ("Value is nil!") end end addCommandHandler("drugrun", drugRunner) addCommandHandler("a", markerHit)
  2. Trust me.. There is a lot more of me to come!
  3. Thank you very much Snake! Could you please tell me exactly what I did wrong and what you edited? I notice the changes in the function, but other than that? Again thank you!
  4. Ty Snake. I have also tried that earlier today, and it gives me the following error: There is something on line 34 thats totally messed up, but I just cant see what it is.
  5. Hi. Wauw.. My 2'nd topic of the day.. Hope I dont make a habit out of this! I have been trying to solve a problem for about 5 hours now. I have asked a few people that have some Lua experience, but I still have no idea how to fix the problem. I have used Google and MTA.Wiki as much as I can, so I have to turn to you guys once again! My problem: I got a script where I want to give the player a certain amount of money, which is defined in a guiCreateEdit box. The function on the serverside, gets the amount of money the player shall get, from the clientside guiCreateEdit. ( Hope this makes sense) But when I run the script I keep getting the error: I'm sure its something very basic that I am missing. I am still new at this and learning! I have outlined the areas in the scripts that needs to be looked at.. Client: -- Creates the admin window -- function createAdminControlWindow() showCursor(true) local X = 0.375 local Y = 0.375 local Width = 0.55 local Height = 0.55 wdwAdminControl = guiCreateWindow(X, Y, Width, Height, "Admin Control Window", true) X = 0.0800 Y = 0.10 Width = 0.15 Height = 0.08 guiCreateLabel(X, Y, Width, Height, "Player Options:", true, wdwAdminControl) -- Slay the player -- Y = 0.20 slayPlayerButton = guiCreateButton(X, Y, Width, Height, "Slay Player", true, wdwAdminControl) addEventHandler("onClientGUIClick", slayPlayerButton, slayPlayerFunction, false) ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ -- Give player X money -- Y = 0.30 giveMoneyButton = guiCreateButton(X, Y, Width, Height, "Give Money", true, wdwAdminControl) addEventHandler("onClientGUIClick", giveMoneyButton, givePlayerMoneyFunction, false) Y = 0.40 giveMoneyEdit = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ -- Find Player Position -- X = 0.750 Y = 0.10 playerPositionButton = guiCreateButton(X, Y, Width, Height, "Get Player Pos", true, wdwAdminControl) addEventHandler("onClientGUIClick", playerPositionButton, playerPositionFunction, false) Y = 0.20 guiCreateLabel(X, Y, Width, Height, "X: ", true, wdwAdminControl) Y = 0.26 guiCreateLabel(X, Y, Width, Height, "Y: ", true, wdwAdminControl) Y = 0.32 guiCreateLabel(X, Y, Width, Height, "Z: ", true, wdwAdminControl) X = 0.800 Y = 0.20 pX = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) Y = 0.26 pY = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) Y = 0.32 pZ = guiCreateLabel(X, Y, Width, Height, "Pos", true, wdwAdminControl) -- Set new Player Position -- X = 0.750 Y = 0.42 setPlayerPositionButton = guiCreateButton(X, Y, Width, Height, "Set New Pos", true, wdwAdminControl) addEventHandler("onClientGUIClick", setPlayerPositionButton, setPlayerPositionFunction, false) Y = 0.52 guiCreateLabel(X, Y, Width, Height, "X: ", true, wdwAdminControl) Y = 0.58 guiCreateLabel(X, Y, Width, Height, "Y: ", true, wdwAdminControl) Y = 0.64 guiCreateLabel(X, Y, Width, Height, "Z: ", true, wdwAdminControl) X = 0.800 Y = 0.52 Height = 0.05 npX = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) Y = 0.58 npY = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) Y = 0.64 npZ = guiCreateEdit(X, Y, Width, Height, "", true, wdwAdminControl) end -- Get Player X,Y,Z, Position -- function playerPositionFunction(thePlayer) local x,y,z = getElementPosition(getLocalPlayer()) guiSetText (pX, x) guiSetText (pY, y) guiSetText (pZ, z) guiSetText (npX, x) guiSetText (npY, y) guiSetText (npZ, z) end -- Set New Player X,Y,Z Position -- function setPlayerPositionFunction() local npX = guiGetText (npX) local npY = guiGetText (npY) local npZ = guiGetText (npZ) triggerServerEvent("movePlayerToPosition",getLocalPlayer(), npX, npY, npZ) end -- Slay The Player -- function slayPlayerFunction() triggerServerEvent("slayPlayer",getLocalPlayer(), getLocalPlayer()) end ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ -- Give The Player X Money -- function givePlayerMoneyFunction() local xAmount = guiGetText (giveMoneyEdit) triggerServerEvent("giveMoney", getLocalPlayer(), xAmount) end ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ function closeAdminControlWindow() guiSetVisible(wdwAdminControl, false) showCursor(false) end addCommandHandler("aO", createAdminControlWindow) addCommandHandler("aC", closeAdminControlWindow) Server: -- Spawn Player on join -- function joinHandler( theplayer ) local x = 1959.55 local y = -1714.46 local z = 18 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("#FFFF66Welcome to the server", getRootElement(), 255, 0, 0, true) end -- Get Player X,Y,Z positions with /myPos command -- function getPlayerPosition(thePlayer, command) local x,y,z = getElementPosition(thePlayer) outputChatBox("#FF0000--- Your X, Y, Z positions are: ---", getRootElement(), 255, 0, 0, true) outputChatBox("X: " .. x) outputChatBox("Y: " .. y) outputChatBox("Z: " .. z) end -- Moved the player to new position, defined in gui.lua -- function moveThePlayer(npX,npY,npZ) spawnPlayer(source,npX,npY,npZ) setCameraTarget(source,source) end -- Slay the player, triggered in gui.lua -- function slayPlayer(sourcePlayer) killPed (sourcePlayer, sourcePlayer) end ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ -- Give the Player money, triggered in gui.lua function giveMoney ( source, xAmount ) givePlayerMoney ( thePlayer, xAmount ) end ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------ addEventHandler("onPlayerJoin", getRootElement(), joinHandler) addCommandHandler("myPos", getPlayerPosition) addEvent("movePlayerToPosition",true) addEventHandler("movePlayerToPosition",root,moveThePlayer) addEvent("slayPlayer",true) addEventHandler("slayPlayer",root,killPed) addEvent("giveMoney",true) addEventHandler("giveMoney", getRootElement(), giveMoney) I hope someone can help me solve the problem, and teach me something too! If you read this, TY for looking
  6. @ CowTurbo - Yeah, I used the changes that you made to my script, and it works 100% as I want it to now Thank you for also pointing out that my outputs are being shown to everybody on the server. Thanks a lot!
  7. No. I want to be able to move/spawn the player at a new position in my guiwindow, like: http://imageshack.us/photo/my-images/822/unavngivetwi.png/ Ignore that the new position is the same as the current, but even if I would click "Set New Pos" at the same location as I am currently on, it would move me to 0, 918, 926.
  8. Hi. I have made a small script where I get the players position, and another script where I can set a new position to spawn/move the player. I get no errors and everything seems to be working fine, but the player is ALWAYS spawned at the same location, no matter what I write in my X,Y,Z guiCreateEdit. Client side: http://pastebin.com/m0ww1KR6 Server side: http://pastebin.com/LY4rFVyx Anyone got an idea about what I am doing wrong? Ty
×
×
  • Create New...