Jump to content

redditing

Members
  • Posts

    111
  • Joined

  • Last visited

Everything posted by redditing

  1. I would like to know how I could get ElementData from server to client and vice versa -- server side marker = createMarker(0, 0, 1.5, "cylinder", 2, 255, 0, 0) setElementData(marker, "Item", 5) addEvent("GetItem", true) addEventHandler("GetItem", root, function() ClientMarker = marker ItemOfClientMarker = getElementData(marker, "Item") end) addEventHandler("onMarkerHit", marker, function(hp) triggerClientEvent("Element", resourceRoot) setElementData(hp, "ItemTwo", ElementVariable+getElementData(marker, "Item")) end) -- client side function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end setElementData(getLocalPlayer(), "ItemTwo", 0) addEvent("Element", true) addEventHandler("Element", root, function() ElementVariable = getElementData(getLocalPlayer() , "ItemTwo") end) addEventHandler("onClientRender", root, function() triggerServerEvent("GetItem", root) dxDrawTextOnElement(ClientMarker, tostring(ItemOfClientMarker), 2, 50, 255, 255, 0, 3, "arial") end) Does it have a chance to work? because that's something I imagine...
  2. -- server side cylinder = createMarker(-712.09100, 967.01917, 12.33547-1, "cylinder", 1.5, 255, 50, 0, 255) setElementData(cylinder, "BoxWithPoints", 0) function TIMER() if getElementData(cylinder, "BoxWithPoints") >= 8 then setElementData(cylinder, "BoxWithPoints", 8) else setElementData(cylinder, "BoxWithPoints", getElementData(cylinder, "BoxWithPoints")+1) end if isElementWithinMarker(source, cylinder) then triggerServerEvent("givePointsToServer", root) PointsServer = getElementData(source, "points") BoxPoints = getElementData(cylinder, "BoxWithPoints") setElementData(source, "points", PointsServer + BoxPoints) setElementData(cylinder, "BoxWithPoints", 0) end end setTimer(TIMER, 3000, 0) -- client side setElementData(getLocalPlayer(), "points", 0) addCommandHandler("ShowMyPoints", function() outputChatBox(tostring(getElementData(getLocalPlayer(), "points")), 255, 255, 0) end) addEvent("givePointsToServer", true) addEventHandler("givePointsToServer", root, function(player) local player = client setElementData(player, "points", getElementData(player, "points")) end) The problem is with the ruler where isElementWithinMarker (source, cylinder) shows me the error that argument 1 got nil, I don't know what to think about it because I checked meta.xml and server side and client side is the correct type, could someone explain why is this happening?
  3. what server-side getLocalPlayer looks like?
  4. That's what I meant about the guy, thanks mate
  5. I would like to know something about ElementData, the most about these two commands {getElementData, setElementData}, could someone help me understand these two things. For example, write a guide that would help me a lot and give me a heart
  6. So I have a question, I have a model to import but I would like this object was only visible in a specific dimension. How can I do this?
  7. I have another question if it can be done so that people from the red team can shoot other players in the head (in the sense that it would kill other players) -- server side red = createTeam("RED", 255, 0 ,0) blue = createTeam("BLUE" , 0, 255, 0) -- client side function RedTeamHeadShotDamage(player, valuedamage, bodypart) if bodypart==9 then killPed(getLocalPlayer()) else cancelEvent() end end function SetRedTeamHeadShotOnly() local redPlayers = getTeamFromName("BLUE") local teamRed = getPlayersInTeam(redPlayers) for i, v in pairs(teamRed) do addEventHandler("onClientPlayerDamage", v, RedTeamHeadShotDamage) end end SetRedTeamHeadShotOnly() Something I mean, can it work?
  8. And with loop i can do it?
  9. Okay, so I would like to give M4 to each person from the "Red" team, and to every player from the "Blue" team I would like to give Ak47, How can I do it? -- server side red = createTeam("Red team", 255, 0, 0) blue = createTeam("Blue team", 0, 255, 0) giveWeapon("red team????", 31, 9999) giveWeapon("blue team????", 30, 9999) Something like this is on my mind but I do not know what to put in the "string" red team and blue team...
  10. Ok i understand, thx
  11. I have a problem with this script will someone help me? function Resource() local res = getResourceFromName("ResourceTest", true) startResource(res) end addCommandHandler("res", Resource)
  12. redditing

    Button

    -- Client Side Button = guiCreateButton(0.45, 0.54, 0.10, 0.06, "Get Value", true) guiSetProperty(Button, "NormalTextColour", "FFAAAAAA") guiSetVisible(Button, false) EditBox= guiCreateEdit(0.41, 0.45, 0.18, 0.04, " chcesz tego kupić sztuk?", true) guiSetProperty(EditBox, "NormalTextColour", "FFFF0000") guiEditSetMaxLength(EditBox, 3) guiSetVisible(EditBox, false) addEventHandler("onClientGUIClick", Button function() local inputBox = tonumber(guiGetEdit(EditBox)) if inputBox==0 then outputChatBox("U set value input "..inputBox, 255, 255, 0) end end) -- Another Client Side addCommandHandler("TurnOnButton", function() guiSetVisible(Button, true) guiSetVisible(EditBox, true) end) I don't know what's wrong, but when I type the command 'TurnOnButton' I can't click the button and the editBox as if they didn't exist
  13. redditing

    BindKey

    I can't show the code because it has 7000 lines What I mean the most is that I have equipment and when I use some things in it, I have to click "i" twice to reset and work normally, so I thought that there is a function that will make me click "bindKey"
  14. redditing

    BindKey

    Maybe I will explain otherwise, I have equipment that I open with the "i" button bindKey("i", "down", Inventory) Well, when I click "i" this is all right, but I would like to click "i" with a script. I would like to run it the same way as SetPedControlState() function setPedControlState(localPlayer, "i", true) But I know that this function doesn't have such a thing, that's why I'm asking if there is a similar function but with the properties I showed in the case of the SetPedControlState () function
  15. redditing

    BindKey

    Is there a function similar to ToogleControl but with Binds? I mean, there is such a function attached to BindKey (under the "k" key), and I would like to press the "k" function just like in ToggleControl, where we clicked eg left mouse button to shoot
  16. YEAH, IT WORKS!! THANKS SO MUCH
  17. 98/5000 So I have a question (hypothetical question) can I return the value using "callServer", "callClient"?
  18. Okay, I have one problem, when I get into this "cylinder" then it gives me a pistol but with 30 bullets despite the fact that "Ammo" has a value of 72 Can you help me with that? -- Client side addEvent("WeaponGetAmmoToServer", true) local Ammo = 72 local AmmoMarker = createMarker(0, 0, 1, "cylinder", 2.0) local WeaponMarker = createMarker(0, 0, 1, "cylinder", 2.0) addEventHandler("onClientMarkerHit", AmmoMarker, function() Ammo = Ammo + 1 end) addEventHandler("onClientMarkerHit", WeaponMarker, function() addEventHandler("WeaponGetAmmoToServer", root, function() return Ammo end) triggerServerEvent("GiveWeaponToPlayer", root) end) -- Server Side addEvent("GiveWeaponToPlayer", true) addEventHandler("GiveWeaponToPlayer", root, function(prl) local prl = client giveWeapon(prl, 22, triggerClientEvent("WeaponGetAmmoToServer", source), true) end) This script return Colt45 with 30 Ammo, but i want 72 from variable
  19. The case looks like this, I have a variable (Let's call it Ammo) that IS TO be in the giveWeapon function (source, 22, Ammo, true) but the problem is that this Ammo variable has the script type "client" and the function is the server script type, so how can I make this variable in this function? If someone has not understood what is going on, there is still a code to simplify... -- Client side local Ammo = 60 local AmmoMarker = createMarker(0, 0, 1, "cylinder", 2.0) local WeaponMarker = createMarker(0, 0, 1, "cylinder", 2.0) addEventHandler("onClientMarkerHit", AmmoMarker, function() Ammo = Ammo + 1 end) addEventHandler("onClientMarkerHit", WeaponMarker, function() -- Here I get a weapon, the variable "Ammo" is the number of bullets end) -- Server Side --??? Problem with importing variable "Ammo"
  20. I know that, i created colissions woth other objects in normal scale and alpha 0
  21. I have an object enlarged by 30 times [SetObjectScale ('object', 30.0)] and my problem is when you look, e.g. slightly to the right, the object disappears, and if you turn left, it suddenly appears. It can be fixed, please help!
  22. I would like to do a recoil system in such a way that a player who is hit by someone is thrown upwards simultaneously E <---- this is element X <---- point position example x x x x x E x
  23. I'm creating a server with minigames, and I'll probably use dimensions to split the maps, and my question is this. If I have a script for a given mini-game, then in every dimension does this script change in its own way ?. I give an example. I have two maps ... the first one is in the first dimension, the name is attached, the script is attached after the player teleports to him and plays with other players who are in the first dimension. But there is also a second dimension with the same script. And this is about whether there will be no undesirable consequences between these two dimensions. For example, with Equipment, at the end of the minigame and resetting it again, I will have to clear Equipment, and I do not know if I will clear the equipment of players who are in this dimension or all who are on the server in general. ; /
×
×
  • Create New...