Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. OMG ! How did I miss that >< You are totally right, I litteraly didn't see the loop ... function renderDisplay ( ) dxDrawImage ( screenWidth/2 + 480, screenWidth/2 - 130, 100, 160, 'body.png', 0, 0 ) local veh = getPedOccupiedVehicle( localPlayer ) local rx, _ = getVehicleTurretPosition ( veh ) rx = math.deg ( -rx ) dxDrawImage ( screenWidth/2 + 504, screenWidth/2 - 155, 50, 130, 'turret.png', x, 0 ) end Here you go, thanks Dealman
  2. If you only have the exact code you pasted, then that's impossible that there is a duplicate. So maybe you did another test somewhere else in the resource or another resource test. Maybe you tried a guiCreateStaticImage somewhere ? Try to stop the resource where this code is, if it's still there, then you know you have to search in another (test ?) resource. If it disapears, then you know you can focus on files from that resource only. It's time to investigate : p
  3. Perfect response right here, can't make it more clear.
  4. Sorry but you didn't provide enough information. What the function exacltly should do ? Can you provide 2 or more examples like: "if I have a table like this and I call the function like this I want the function to return that." Why do you need an "index" in your situation ?
  5. Citizen

    setElementData

    Alright then why didn't you just say that in the first post ??? We need to see the code responsible of showing and hiding the nametag, we can't hack your computer to see by ourselves, provide everything that can be usefull for us to help you.
  6. Citizen

    setElementData

    Alright so thanks to the video, I understood that you wanted to have a maximum of one bubble at a time. If you read the script carefully, you will see that the number of bubbles to be drawn at the same time is managed by the maxbubbles variable at the top of the script which is populated by the saveSettings function at the bottom of the script. That same function is triggered from the serverside and probably use the setting system in the meta.xml. Can you show us the onAskForBubbleSettings event on the serverside and your meta.xml ?
  7. Wow this looks pretty cool, would like to see it when it's done For the rotation I guess calculating the degree rotation of the opposite radian rotation would do the trick. (so x = math.deg( -x ) or using -x in dxDrawImage): (I renamed x to rx just to avoid confusion) function renderDisplay ( ) dxDrawImage ( screenWidth/2 + 480, screenWidth/2 - 130, 100, 160, 'body.png', 0, 0 ) local vehicles = getElementsByType ( "vehicle" ) for vehicleKey, veh in ipairs(vehicles) do local rx, _ = getVehicleTurretPosition ( veh ) rx = math.deg ( -rx ) -- Here i'm calculating the oposite by doing '-rx' dxDrawImage ( screenWidth/2 + 504, screenWidth/2 - 155, 50, 130, 'turret.png', x, 0 ) end end For the rotation pivot, edit the turret.png so the center of the entire image is placed where you want the rotation pivot to be. For the duplicated turret image, I guess that body.png does have the turret already which have to be removed using photoshop or something. If not, can send us both images so I can test it on my side ?
  8. You were actually cleaning the player instead of the vehicle, becarefull with what stores your variables: client: local myShader = dxCreateShader("texture.fx") addEventHandler("onClientElementDataChange", root, function (dataName) if getElementType(source) == "vehicle" and dataName == "Cleaned" then local newValue = getElementData(source, dataName) -- DEBUG output below, to be removed when done with tests: outputChatBox("[DEBUG]'Cleaned' element data changed: "..tostring(newValue)) -- Check here if newValue is true to remove the shader and false to apply it ? engineApplyShaderToWorldTexture(myShader, "vehiclegrunge256", source) engineApplyShaderToWorldTexture(myShader, "?emap*", source) end end) server: local x,y,z = 1911.2, -1776, 12 local Marker = createMarker(x, y, z, "cylinder", 5, 255, 0, 0, 150) local gate = createObject(968, 1915.5, -1771.80, 13, 0, -90) local gate1 = createObject(968, 1915.5, -1780.85, 16, 0, -90) addEventHandler("onMarkerHit", Marker, function (hitPlayer) if getElementType(hitPlayer) ~= "player" or getPedOccupiedSeat(hitPlayer) ~= 0 then return end local theVehicle = getPedOccupiedVehicle(hitPlayer) if theVehicle then setElementData(theVehicle, "Cleaned", true) fadeCamera(hitPlayer, false, 2.5, 0, 0, 0) setTimer(fadeCamera, 2500, 1, hitPlayer, true, 2.5) moveObject(gate, 9000, 1915.5, -1771.80, 16) moveObject(gate1, 2000, 1915.5, -1780.85, 13) outputChatBox("Your Welcome in car wash", hitPlayer, 0, 255, 255) end end) addEventHandler("onMarkerLeave", Marker, function (hitplayer) if getElementType(hitPlayer) ~= "player" or getPedOccupiedSeat(hitPlayer) ~= 0 then return end moveObject(gate, 2000, 1915.5, -1771.80, 13) moveObject(gate1, 9000, 1915.5, -1780.85, 16) end) Just for your information, when driving a vehicle into a marker, onMarkerHit will be called 2 (or more times): 1 for the vehicle itself, and at the very same time, 1 per passenger (driver included). If a vehicle with 4 players inside (1 driver and 3 passengers) your function for onMarkerHit will be called 5 times (1 time for the vehicle, another time for the driver, and again for each passenger). That's why I'm also cancelling the function if the hitPlayer is not the driver (a passenger or someone on foot). @Dimos7: Thank you for trying to help but for me you don't have the skill yet to be able to answer with a good solution on this forum. You are introducing bugs, breaking things that were already working (like breaking the marker creation ... Seriously how did you remove the 'r' in 'creationMaker', it's 'creationMarker'. @Tox: If you have read the wiki, you would have seen that by default the synchronize argument is already true, so it wasn't the problem and is useless to specify true again. Best regards, Citizen
  9. Images are broken, can you reupload them somewhere like gyazo or imgur ? (Well, somewhere where it's actually working ?)
  10. Please read the wiki before asking for help, everything is explained and it would save time for you and for us ! From spawnPlayer Wiki page: function spawnPed () spawnPlayer( source, -711, 957, 12.382266998291) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler( "onPlayerJoin", getRootElement(), spawnPed )
  11. Citizen

    code not work

    The problem with your code is that your timer is calling only one function which is setVehicleColor every 1 second with the given arguments instead of: 1 - regenerating the r, g, b values AND THEN 2 - call the setVehicleColor with the new values. So your rainbow timer needs to do 2 things instead of one. As the setTimer can only call one function, you have to wrap the 2 things inside a new function that will do both (l.14-17): function rainbowColor(thePlayer) if isPedInVehicle(thePlayer) then local theVehicle = getPedOccupiedVehicle(thePlayer) local rainbowTimer = getElementData(theVehicle, "rainbowTimer") -- getting the rainbowTimer from the vehicle (false if none has been saved yet) if isTimer(rainbowTimer) then -- if the timer already exists for that vehicle then killTimer(rainbowTimer) -- just stop it (no need to take money to stop it) return -- we are done, stop the function end -- If we get there, it means that the vehicle doesn't have rainbow timer activated so let's create it local money = getPlayerMoney(thePlayer) if money >= 10000 then takePlayerMoney(thePlayer, 10000) local rainbowTimer = setTimer(function (veh) local r, g, b = math.random(0, 255), math.random(0, 255), math.random(0, 255) setVehicleColor(veh, r, g, b) end, 1000, 0, theVehicle) setElementData(theVehicle, "rainbowTimer", rainbowTimer, false) -- saving the rainbowTimer in the vehicle element else outputChatBox("You do not have enough money for this ! ($10000 required)", thePlayer, 255, 0, 0) end else outputChatBox("You have to be in a vehicle to do that !", thePlayer, 255, 0, 0) end end addCommandHandler("rainbow", rainbowColor) One potential problem with this is that anyone inside the vehicle can turn the rainbow thing on and off. I mean for example, you (Dimos7) are the owner of the vehicle, you do /rainbow to start it, then I (Citizen) can turn it off by doing /rainbow too but on a passenger seat. A solution would be to replace this: if isPedInVehicle(thePlayer) then by this: if getPedOccupiedVehicleSeat( thePlayer ) == 0 then Which will only allow the driver to use the command for the vehicle. Best regards, Citizen
  12. You can't do that as you will also detect "I need 25 $". Dude you are going too far with that Anti-ip advertisement ! And "My ip is 180" is not an IP so how can it be an advirtisement ? You are going to ban all numbers on your server.
  13. Citizen

    SQL Problem

    no, INTEGER, more infos: https://en.wikipedia.org/wiki/Unix_time
  14. spIndex is not the index of the spawn, but it is the spawn itself already ! (Like you did for the skin variable at line 66 (line 10 here)) function SpawnPlayers() local mapSpawns = getElementsByType("spawnpoint") print("number spawns: "..#mapSpawns.." players: "..#playersTable) for k, v in ipairs(playersTable) do local spawn = mapSpawns[math.random(#mapSpawns)] local x = getElementData(spawn, "posX") local y = getElementData(spawn, "posY") local z = getElementData(spawn, "posZ") local rot = math.random(359) local skin = playerSkins[math.random(#playerSkins)] spawnPlayer(v, x, y, z, rot, skin) setPlayerTeam(v, playerTeam) end end
  15. Even if toni is right, you don't want to check that every 60ms (~17 times per second)! This is an obvious waste of server resources ! I would make an updatePlayerClassIcon function instead and call it when it needs to be updated: function updatePlayerClassicon() local accName = getAccountName( getPlayerAccount( source ) ) local aclName = "user."..accName local classIcon = "Player" -- By default he has the "Player" Classicon if isObjectInACLGroup( aclName, aclGetGroup( "Admin" ) ) then classIcon = "Admin" -- Modify it if needed else if isObjectInACLGroup( aclName, aclGetGroup( "Moderator" ) ) then classIcon = "Moderator" -- Modify it if needed else if isObjectInACLGroup( aclName, aclGetGroup( "SuperModerator" ) ) then classIcon = "SuperModerator" -- Modify it if needed else if isObjectInACLGroup( aclName, aclGetGroup( "Warden" ) ) then classIcon = "Warden" -- Modify it if needed else if isObjectInACLGroup( aclName, aclGetGroup( "Vip" ) ) classIcon = "Vip" -- Modify it if needed end setElementData( source, "Classicon", classIcon ) -- setting the Classicon end addEventHandler("onPlayerJoin", root, updatePlayerClassicon) addEventHandler("onPlayerLogin", root, updatePlayerClassicon) addEventHandler("onPlayerLogout", root, updatePlayerClassicon)
  16. Citizen

    SQL Problem

    You don't really now what you are doing right ? The error message can't be clear enough ... At line 7 you are trying to create a MySQL table with multiple "username" columns. Same with the following columns "by" and "reason". You can't create 2 columns with the exact same name. You have 2 solutions: The first one is to use different tables for each punishment type: function createTable() connection = dbConnect("sqlite", "database.db") if connection then dbExec(connection, "CREATE TABLE IF NOT EXISTS `accounts`('username', 'password', 'name', 'serial', 'kills', 'deaths', 'headshots', 'money', 'rank', 'exp', 'class', 'playtime', 'vip', 'adminlevel')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `warns`('playername', 'by', 'reason')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `jails`('playername', 'jailtime', 'by', 'reason')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `kicks`('playername', 'by', 'reason')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `bans`('playername', 'serial', 'bantime', 'by', 'reason')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `mutes`('playername', 'mutetime', 'by', 'reason')") end end addEventHandler("onResourceStart", resourceRoot, createTable) The second one would be to use a column named "type" to know what kind of punishement it is so you can share the same columns: function createTable() connection = dbConnect("sqlite", "database.db") if connection then dbExec(connection, "CREATE TABLE IF NOT EXISTS `accounts`('username', 'password', 'name', 'serial', 'kills', 'deaths', 'headshots', 'money', 'rank', 'exp', 'class', 'playtime', 'vip', 'adminlevel')") dbExec(connection, "CREATE TABLE IF NOT EXISTS `punishments`('type', 'playername', 'serial', 'by', 'reason', 'starttime', 'finishtime')") end end addEventHandler("onResourceStart", resourceRoot, createTable) So in the "type" column, you will use the following values: For a warn => 1 For a mute => 2 For a jail => 3 For a kick => 4 For a ban => 5 The "starttime" column will contain the timestamp when the pusnishment occured ( getRealTime().timestamp to get the current timestamp) and the "finishtime" will contain the timestamp when the punishment will be over ( getRealTime().timestamp + 7 * 24 * 3600 to calculate the timestamp it will be in 7 days from now) Here is how your table can look like if you apply some punishments: typeplayernameserialbyreasonstarttimefinishtime 1 Citizen 123E456C4 Dimos7 Do not spam 1457714436 NULL 2 Citizen 123E456C4 Dimos7 Spamming too much 1457714436 1457714456 3 Citizen 123E456C4 Dimos7 Killing for no reason 1457714436 1457714456 4 Citizen 123E456C4 Dimos7 Respect others 1457714436 NULL 5 Citizen 123E456C4 Dimos7 MultiAccount is forbidden 1457714436 1457714456 5 Citizen 123E456C4 Dimos7 Aimbot 1457714436 NULL Hope it helps.
  17. If you only need a list of player's name on your server: function getAllPlayersForWebsite ( ) local players = {} for k, player in ipairs( getElementsByType ("player") ) do local name = getPlayerName( player ) table.insert( players, name ) end return players end If you also need their ids: function getAllPlayersForWebsite ( ) local players = {} for k, player in ipairs( getElementsByType ("player") ) do local id = getElementID( player ) local name = getPlayerName( player ) table.insert( players, {id, name} ) end return players end
  18. Citizen

    I need help

    No, on the client-side, the function signature of outputChatBox is: bool outputChatBox ( string text [, int r=231, int g=217, int b=176, bool colorCoded=false ] ) and doesn't accept the visibleTo like the server-side version. If you need to do it from the client side, you have to use triggerServerEvent on an event you will create on the server-side and use that event to call a function in which you will use your outputChatBox.
  19. Citizen

    guiSetProperty

    Would like to know where they say you had to use tl, tr, bl, br. @DakiLLa ? Back in the day when I was busy with some GUI related stuff I found this thing. Thank you ! Bookmarked it.
  20. Citizen

    guiSetProperty

    Would like to know where they say you had to use tl, tr, bl, br. @DakiLLa ?
  21. Citizen

    I need help

    Its just a part of my code and its working fine, but I want only "leave" can be spammed Hmmm okay then just replace this line: if text == msg then by this line: if text == msg and text ~= "leave" then or this line if you don't want it to be case-sensitive: if text == msg and string.lower(text) ~= "leave" then
  22. Citizen

    I need help

    First, are you sure that the current code is working ?? It looks like you truncated some parts needed for that code to work. A code should be working before extending it.
  23. In case no one wants to teach you, a good start is to read the Wiki, especially the Introduction to Scripting. Best regards, Citizen
  24. Code please meta.xml content please
  25. What gamemode are you using ? What resources can use the onNextMap event ? When is the error appearing ? If it is when you are changing map, do the error appears everytime ?
×
×
  • Create New...