Jump to content

SpecT

Members
  • Posts

    656
  • Joined

  • Days Won

    9

Everything posted by SpecT

  1. Hey, There is a chance the player to get an error - the client side event is not attached to any function. When the "onPlayerJoin" is triggered the player might still be downloading -> the player still doesn't have the client side loaded -> error. I don't get it why would you want to bind the key in the server side and "onPlayerConnect". It would have had more logic if it was onPlayerLogin (i.e. to check if has enough rights but you didn't mention something like that). Anyways you can easily put the bindKey function in the client script out of any functions and it will bind the key on client resource load. function asd() -- something end bindKey("F1", "down", asd) Or use the onClientResourceStart event.
  2. Well you keep telling that everything we post here doesn't work (even tho I tested). So please be more specific - doesn't work OR it's not what you need. Because there is a difference! It would be best to show the code where you tried and tell us what's wrong with it and what you want to achieve. Also you mentioned you got errors in debugscript so it would be good if you show them as well.
  3. Well, you will need to use tables when it comes to more elements (jobs). I don't know maybe something like this ? function duty(thePlayer) local jobsCount = 10 local foundJob = false for i=1, jobsCount do local checkjob = getElementByID(tostring(i)) if type(checkjob) == "marker" then if isElementWithinMarker(thePlayer, checkjob) then outputChatBox("this marker is for job number "..i, thePlayer, 255, 0, 0) foundJob = true break -- if it finds the marker the player is in => stop the loop end end end if not foundJob then outputChatBox("not within a marker", thePlayer, 255, 0, 0) end end addCommandHandler("duty", duty)
  4. You don't need to use loop since you already got the elements (markers) by ID. So you just check if the player is within them. function duty(thePlayer) local checkjob = getElementByID("1") local checkjob2 = getElementByID("2") if type(checkjob) == "marker" and type(checkjob) == "marker" then -- just to be sure they are markers if isElementWithinMarker(thePlayer, checkjob) then outputChatBox("1 job", thePlayer, 255, 0, 0) elseif isElementWithinMarker(thePlayer, checkjob2) then outputChatBox("2 job", thePlayer, 255, 0, 0) else outputChatBox("not marker", thePlayer, 255, 0, 0) end end end addCommandHandler("duty", duty)
  5. Could you show the code on line 28 ?
  6. I don't think you need the "..." since you will have only 2 arguments. You will need the "..." in case you are sending a message (i.e. PMs). Also why would you send the error message to all the players in the server ? Isn't it supposed to be only for the player who used the command ? I don't get exactly what your idea is tho but this might be useful to you: function paymoney(player,cmd, arg1, arg2) if not arg1 and not arg2 then outputChatBox ("Wrong command syntax. Example: /pay 1 1",player,255,255,255,false) return end if not arg2 then outputChatBox ("No ammount specified. Example: /pay 1 1",player,255,255,255,false) return end -- your stuff here end addCommandHandler("pay",paymoney)
  7. Hey, Here is an example meta.xml file with "min_mta_version" section: <meta> <info type="gamemode" name="Test" author="Test" /> <min_mta_version server="1.5.4-9.11342" /> </meta>
  8. If you only want to see them and don't need to store them in a table (for later use) then this should do the job: addEventHandler("onResourceStart", resourceRoot, function(res) -- res = the resource that just started local resourceName = getResourceName(res) local commands = getCommandHandlers(res) -- get all commands from the resource outputChatBox("Commands found in "..resourceName..":", root, 255, 255, 255) for _, command in pairs(commands) do outputChatBox(command, root, 255, 255, 255) end end)
  9. The problem is that getElementPosition returns exact coordinates (in this case X coordinate is "-715.83142089844"). And you are comparing it with "-715.8314". To make it work you will have to round the coordinates. You can either use the useful function math.round or do it like this: local theBlip = createBlip(-715.8314, 2328.1269, 44.1525, 41, 2, 255, 0, 0, 255, 0, 1000) function removeBlip(posX, posY, posZ) for _,blip in ipairs(getElementsByType("blip")) do local x,y,z = getElementPosition(blip) if(math.ceil(posX) == math.ceil(x) and math.ceil(posY) == math.ceil(y) and math.ceil(posZ) == math.ceil(z)) then destroyElement(blip) end end end addCommandHandler("blip", function () -- the cmd way is for an example removeBlip(-715.8314, 2328.1269, 44.1525) end) *Changed @Burak5312's code a bit. Note that this way it won't be very accurate but if you don't plan to have close blips it should not cause any problems. Otherwise use the math.round function I mentioned above and specify how many digits to have after the decimal point.
  10. SpecT

    Help | Webhook

    Hey, Dunno but "getResourdiscordName" doesn't look to me like a normal function name. ?
  11. You will have to create a variable which will be for your alpha. All your images' and texts' alpha value will have to be multiplied by this variable. If the mouse is not in the position set this variable's value to 0.5 (for example) else 1. Something like this: function gui() local alpha = 1 if not isMouseInPosition(...) then alpha = 0.5 end dxDrawImage(..., tocolor(255, 255, 255, 255*alpha), ...) ... end
  12. You're welcome! And don't worry we all have been there.
  13. Hey, You used the getCursorPosition function wrongly. It doesn't take arguments but returns them. You can check examples in the link above. For your case you will need the useful function on the wiki: IsMouseInPosition. You will need to add the function in your script and then replace your "getCursorPosition" with "isMouseInPosition".
  14. Hey, Don't forget that variable names are case sensitive! local Vendedor = createPed( 179, 308.36, -143.3 , 999.602 , 0 ) local Vendedor1 = createPed( 179, 316.48, -133.333, 999.602 , 90 ) And now check the names you used in the damage events. Do you notice something wrong ? ?
  15. Well if "hascharacter" can have only 2 states (0 and 1) then you could put in the query at the WHERE part to be like WHERE 'hascharacter' = '1' And then if the countOfResults is 0 that means the account has this column set to 0; if its 1 it will return you 1 result => countOfResults will be 1. Btw why isn't there an account id/username specified ? Currently if there are 2 or more accounts with "hascharacter" set to 1 it will return you the times it was found. Maybe the query should be: SELECT `id` FROM `accounts` WHERE `id` = `?` AND `hascharacter` = `1` You will need to pass the account ID or username in the dbQuery.
  16. The thing is I tried a lot of stuff (hitting, shooting) to them. They keep rotating even while dead and laying on the ground. I increased the loop for ped spawning to 100 to make sure it won't break with more peds. And in the end they all keep rotating to me with no exclusion.
  17. I just tested both the full and the simplified scripts and they work as expected. So maybe there is another script which also sets the rotation of peds on your server? I don't know what exactly could be but it's not from the script (if this helps at all).
  18. Welcome to the Forums! To do that you will need to use getElementModel function to get vehicle's model ID. Like this: local shootTimer = nil function shoot() local vehicle = getPedOccupiedVehicle(localPlayer) -- stop if "vehicle" is not an element or if its not infernus (411) if not isElement(vehicle) or getElementModel(vehicle) ~= 411 then return end if(not isTimer(shootTimer))then local posX, posY, posZ = getElementPosition(vehicle) shootTimer = setTimer(function()end, 5000, 1) createProjectile(vehicle, 19, posX, posY, posZ, 1.0) end end bindKey("vehicle_fire", "down", shoot) bindKey("vehicle_secondary_fire", "down", shoot)
  19. There are a few threads on the forum with the same subject. Don't be shy to use the search feature! ? Here is what I found which might be the answer for you (not written by me): function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end
  20. Do you at least get the "u got it" message ?
  21. Well then keep in mind that the check for opexp is if its EXACTLY 2500 (not more not less). The code @Erlkonig posted should work just fine except the setElementData part where it converts the money (number) to string which doesn't make sense to save money as string. So maybe something like this: function bp() local gnrl = getElementData(source,"Money") or 0 -- if gnrl is new and uses only here use local gnrl = ... local opexp = getElementData(source,"opexp") or 0 if tonumber(opexp) == 2500 then -- if opexp can be more than 2500 then replace == with >= local new_money = tonumber(gnrl) + 1000 -- you should be sure that "Money" is number. setElementData(source, "Money", new_money) outputChatBox("u got it", source, 255, 0, 0) end end
  22. What exactly doesn't work ? Is it expected to get money if your EXP is 2500 or more ? Please be more specific on what's wrong so we could understand and help you.
  23. Hey, The function isElementInRange is called a "useful" function because it's not hardcoded but you have to put it in your script. On the documentation (^) page everything is explained. You haven't shown us any code where we can see what you tried. I don't know what your idea is so I'm just gonna give you an example how to use it (taken from the Wiki page). function playerInRange(player, cmd) local x, y, z = 1492, 1444, 0 -- example location coordinates if isElementInRange (player, x, y, z, 25) then -- check if the player is near the location; range 25m -- do your stuff here else outputChatBox("You are not in range!", player) end end addCommandHandler("check", playerInRange) function isElementInRange(ele, x, y, z, range) if isElement(ele) and type(x) == "number" and type(y) == "number" and type(z) == "number" and type(range) == "number" then return getDistanceBetweenPoints3D(x, y, z, getElementPosition(ele)) <= range -- returns true if it the range of the element to the main point is smaller than (or as big as) the maximum range. end return false end
  24. Maybe you didn't take a close look on what @Tekken posted. You are missing the argument "player" in the function storerob(). Also to make those timers work you will need to pass them the player element as well - as an optional argument (check setTimer documentation). It should be something like this: -- 1352 , -1769 , 14 function storerob(player) --if x <= 1356 and x >= 1348 then --if y <= -1773 and y >= -1765 then --outputChatBox("you are here ", player, 0, 0, 0) --------------------------------------------------------------------------------------------- outputChatBox(" ", root, 0, 0, 0) outputChatBox("-----------------------------------------------------", root, 255, 0, 0) outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0) outputChatBox("-----------------------------------------------------", root, 255, 0, 0) outputChatBox(" ", root, 0, 0, 0) --------------------------------------------------------------------------------------------- function loope(player) outputChatBox("Robbing the money ...", player, 0, 255, 0) end setTimer(loope, 1000, 29, player) --------------------------------------------------------------------------------------------- function money2(player) money = math.random(200000, 400000) givePlayerMoney( player, money ) outputChatBox(" ", player, 0, 0, 0) outputChatBox("------------------------------------------------------", player, 0, 255, 0) outputChatBox("You got $"..money.." by robbing a Store !! ", player, 0, 255, 0) outputChatBox("------------------------------------------------------", player, 0, 255, 0) outputChatBox(" ", player, 0, 0, 0) givePlayerMoney( player, money ) end --------------------------------------------------------------------------------------------- setTimer(money2, 30000, 1, player) --else --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0) --end --else --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0) --end end addCommandHandler("robstore", storerob) *PS: Please, use the "code" tool in the text editor when you paste Lua code.
  25. SpecT

    chat

    Well, the command "me" is hardcoded and it doesn't trigger the onPlayerChat event if no text was written. So you can't detect that. Except if there are 2 or more SPACEs in the input. And also unfortunately (but probably for security reasons) you can't get the arguments used in a command from onPlayerCommand event so this is not a variant as well. So I don't think you can check if the "me" message is empty.
×
×
  • Create New...