-
Posts
731 -
Joined
-
Last visited
-
Days Won
2
Everything posted by koragg
-
Can you explain some more? How did you do it?
-
Hello people. So recently i started the single player mod i made years back called GTA Mysterious Mod (available on piratebay) and noticed one awesome feature that I've put in it. Indeed - the ability for some vehicles to do a wheelie. I'm asking here if anybody knows of such resource or has an idea or code or whatever on how to make such a thing for MTA. Today i installed a cockpit view in my race server and i think a wheelie option for cars like phoenix, buffalo, clover would be awesome. Here's a link to the single player cleo mod which does it for GTA SA: https://www.gtaall.com/gta-san-andreas/cleo/60010-car-wheelie.html Also handling or speed of cars shouldn't change at all while doing a wheelie (aka to be default ones). I don't know if using setElementPosition would work. Also i don't know how to get just the vehicle's front part as an element (not the whole vehicle). But if bikes can do it why not cars too? Method should be the same ... hopefully we can make this.
-
https://wiki.multitheftauto.com/wiki/TriggerClientEvent As he said "from server side".
-
Done @pa3ck Here's how I did it: race_toptimes/toptimes_server.lua function deltops( player, cmd, place ) if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then return end if g_SToptimesManager and g_SToptimesManager.mapTimes then local row = g_SToptimesManager.mapTimes:deletetime(place) if row then g_SToptimesManager:updateTopText() local mapName = tostring(g_SToptimesManager.mapTimes.mapName) local placeText = place and "#" .. tostring(place) .. " " or "" local slotDesc = "#FF0000" .. placeText .. "#00FF00[" .. tostring(row.timeText) .. "]#00FFFF from #FFFFFF" .. tostring(getAccountData(getAccount(row.playerName), "currentPlayerName")) .. "#FFFFFF" local adminName = tostring(getPlayerNameWithColor(player)) local adminLogName = getAdminNameForLog(player) for _, p in ipairs(getElementsByType("player")) do outputChatBox("#00FFFFToptime " .. slotDesc .. "#00FFFF deleted by " .. adminName .."#00FFFF!", p, 235, 115, 70, true) end outputServerLog( "Toptimes: " .. adminLogName .. " deleted " .. slotDesc .. " from map '" .. mapName .. "'" ) if tonumber(place) == 1 or not place then executeCommandHandler("deleteghost", player) end end end end addCommandHandler( "deletetime", deltops) addCommandHandler( "deletetop", deltops) addCommandHandler( "deltime", deltops) addCommandHandler( "deltop", deltops) raceghost/record_server.lua function delGhost(client) local accName = getAccountName(getPlayerAccount(client)) local currentMap = exports.mapmanager:getRunningGamemodeMap() local mapName = getResourceName(currentMap) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..accName, aclGetGroup("SuperModerator")) then fileDelete( "ghosts/"..mapName..".ghost" ) outputServerLog("Ghost record for "..mapName.." deleted!") end end addCommandHandler("deleteghost", delGhost) for helping me out yet again
-
That^ didn't work but I found out why it's not working. The "if place == 1 then" part is never true (idk why) and the event never gets triggered. I tried this and it worked perfectly with the command even while the ghost was active (moving): raceghost/record_server.lua addEvent("onGhostDataDelete") function delGhost(client) local accName = getAccountName(getPlayerAccount(client)) local currentMap = exports.mapmanager:getRunningGamemodeMap() local mapName = getResourceName(currentMap) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..accName, aclGetGroup("SuperModerator")) then fileDelete( "ghosts/"..mapName..".ghost" ) outputChatBox("Ghost record for "..mapName.." deleted!", client, 255, 0, 0, true) end end addEventHandler("onGhostDataDelete", g_Root, delGhost) addCommandHandler("deleteghost", delGhost) The only problem is that I don't know how to check if the deleted toptime is indeed a top1 or not in the race_toptimes function which deletes toptimes. As if it's a top2-top9, the ghost shouldn't be deleted. If I do a correct check for a top1, then it's easy to just use executeCommandHandler or to trigger the event (both ways do same thing, personal preference).
-
local mapName = false if place == 1 then local currentMap = exports.mapmanager:getRunningGamemodeMap() mapName = getResourceName(currentMap) end addEvent("onMapStarting", true) function delGhost() if mapName then triggerServerEvent("onGhostDataDelete", getRootElement(), mapName) end end addEventHandler("onMapStarting", root, delGhost) First part of code is in toptimes' /deletetime command function. If the deleted top is a top1 it records the current map's name into 'currentMap' and then gets the resource name in 'mapName'. Second part is a seperate function checking if 'mapName' is not false, and if it's not, it triggers the event to delete ghost of previous map as the 'mapName' contains the resource name of the previous map (the one in which an admin has wrote /deletetime 1). @pa3ck Something like this?
-
Is that even possible
-
When map loads it loads the ghost file as well. When countdown ends the ghost starts moving. So I'd say yes, it's active throughout the whole map (even while I'm trying to delete it). Now it's another thing that I'm not sure if it keeps requesting and recieving data while it's moving or it gets all it's data on map start.
-
Well the ghost is active while the map is running. I don't know if that's the problem... but how to delete it then? I mean, it's made to be active (moving) after countdown ends to show how the top1 player drove.
-
Nobody knows? I asked a friend and he didn't find any mistakes either... so why isn't it working?
-
I thought that this would be easy but I really have no idea what I am doing wrong here. I just want when admin types /deletetime the ghost file of that map to be deleted as well. Here's my code, no idea why it's not working, no errors too. race_toptimes/toptiems_server.lua function deltops(player, cmd, place) if not _TESTING and not isPlayerInACLGroup(player, g_Settings.admingroup) then return end if g_SToptimesManager and g_SToptimesManager.mapTimes then local row = g_SToptimesManager.mapTimes:deletetime(place) if row then g_SToptimesManager:updateTopText() local mapName = tostring(g_SToptimesManager.mapTimes.mapName) local placeText = place and "#"..tostring(place).." " or "" local slotDesc = "#FF0000"..placeText.."#00FF00["..tostring(row.timeText).."]#00FFFF from #FFFFFF"..tostring(getAccountData(getAccount(row.playerName), "currentPlayerName")).."#FFFFFF" local adminName = tostring(getPlayerNameWithColor(player)) local adminLogName = getAdminNameForLog(player) for _, p in ipairs(getElementsByType("player")) do outputChatBox("#00FFFFToptime "..slotDesc.."#00FFFF deleted by "..adminName.."#00FFFF!", p, 235, 115, 70, true) end outputServerLog("Toptimes: "..adminLogName.." deleted "..slotDesc.." from map '"..mapName.."'") if place == 1 then local currentMap = exports.mapmanager:getRunningGamemodeMap() local mapName = getResourceName(currentMap) triggerServerEvent("onGhostDataDelete", getRootElement(), mapName) end end end end addCommandHandler("deletetime", deltops) addCommandHandler("deletetop", deltops) addCommandHandler("deltime", deltops) addCommandHandler("deltop", deltops) raceghost/record_server.lua addEvent("onGhostDataDelete", true) function delGhost(mapName) -- Delete current ghost if fileExists("ghosts/"..mapName..".ghost") then fileDelete("ghosts/"..mapName..".ghost") end end addEventHandler("onGhostDataDelete", g_Root, delGhost)
-
guiSetInputMode("no_binds_when_editing") has to be inside a function. So do this: function noBinds() guiSetInputMode("no_binds_when_editing") end addEventHandler("onClientResourceStart", root, noBinds) Sorry if there are typos. I'm from phone and using code option is :~ af
-
Try : getPlayerFromPartialName (targetPlayer) https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName That's not a built-in mta function so you'll need to copy the whole wiki code into your file before using it.
-
@pa3ck Thanks for taking time to create that man, really appreciate it Here's the final code which works onPlayerJoin. I think quite a lot of users would want this at their server so that's why I'm releasing my final edited version here. It displays city and country when a player joins, and if he joins from a local PC to his local server it will show "San Andreas" as country. Thanks again for the help countryNames = { ['AD'] = 'Andorra', ['AE'] = 'United Arab Emirates', ['AF'] = 'Afghanistan', ['AG'] = 'Antigua and Barbuda', ['AI'] = 'Anguilla', ['AL'] = 'Albania', ['AM'] = 'Armenia', ['AO'] = 'Angola', ['AP'] = 'ARIPO', ['AR'] = 'Argentina', ['AT'] = 'Austria', ['AU'] = 'Australia', ['AW'] = 'Aruba', ['AZ'] = 'Azerbaijan', ['BA'] = 'Bosnia and Herzegovina', ['BB'] = 'Barbados', ['BD'] = 'Bangladesh', ['BE'] = 'Belgium', ['BF'] = 'Burkina Faso', ['BG'] = 'Bulgaria', ['BH'] = 'Bahrain', ['BI'] = 'Burundi', ['BJ'] = 'Benin', ['BM'] = 'Bermuda', ['BN'] = 'Brunei Darussalam', ['BO'] = 'Bolivia', ['BQ'] = 'Bonaire', ['BR'] = 'Brazil', ['BS'] = 'Bahamas', ['BT'] = 'Bhutan', ['BV'] = 'Bouvet Island', ['BW'] = 'Botswana', ['BY'] = 'Belarus', ['BZ'] = 'Belize', ['CA'] = 'Canada', ['CD'] = 'Congo', ['CF'] = 'Central African Republic', ['CG'] = 'Congo', ['CH'] = 'Switzerland', ['CI'] = 'Cote d?Ivoire', ['CK'] = 'Cook Islands', ['CL'] = 'Chile', ['CM'] = 'Cameroon', ['CN'] = 'China', ['CO'] = 'Colombia', ['CR'] = 'Costa Rica', ['CU'] = 'Cuba', ['CV'] = 'Cape Verde', ['CW'] = 'Curacao', ['CY'] = 'Cyprus', ['CZ'] = 'Czech Republic', ['DE'] = 'Germany', ['DJ'] = 'Djibouti', ['DK'] = 'Denmark', ['DM'] = 'Dominica', ['DO'] = 'Dominican Republic', ['DZ'] = 'Algeria', ['EC'] = 'Ecuador', ['EE'] = 'Estonia', ['EG'] = 'Egypt', ['EH'] = 'Western Sahara', ['ER'] = 'Eritrea', ['ES'] = 'Spain', ['ET'] = 'Ethiopia', ['FI'] = 'Finland', ['FJ'] = 'Fiji', ['FK'] = 'Malvinas', ['FO'] = 'Faroe Islands', ['FR'] = 'France', ['GA'] = 'Gabon', ['GB'] = 'United Kingdom', ['GD'] = 'Grenada', ['GE'] = 'Georgia', ['GG'] = 'Guernsey', ['GH'] = 'Ghana', ['GI'] = 'Gibraltar', ['GL'] = 'Greenland', ['GM'] = 'Gambia', ['GN'] = 'Guinea', ['GQ'] = 'Equatorial Guinea', ['GR'] = 'Greece', ['GT'] = 'Guatemala', ['GW'] = 'Guinea-Bissau', ['GY'] = 'Guyana', ['HN'] = 'Honduras', ['HR'] = 'Croatia', ['HT'] = 'Haiti', ['HU'] = 'Hungary', ['ID'] = 'Indonesia', ['IE'] = 'Ireland', ['IL'] = 'Israel', ['IM'] = 'Isle of Man', ['IN'] = 'India', ['IQ'] = 'Iraq', ['IR'] = 'Iran', ['IS'] = 'Iceland', ['IT'] = 'Italy', ['JE'] = 'Jersey', ['JM'] = 'Jamaica', ['JO'] = 'Jordan', ['JP'] = 'Japan', ['KE'] = 'Kenya', ['KG'] = 'Kyrgyzstan', ['KH'] = 'Cambodia', ['KI'] = 'Kiribati', ['KM'] = 'Comoros', ['KN'] = 'Saint Kitts and Nevis', ['KP'] = 'Korea', ['KR'] = 'Korea', ['KW'] = 'Kuwait', ['KY'] = 'Cayman Islands', ['KZ'] = 'Kazakhstan', ['LA'] = 'Lao People?s Republic', ['LB'] = 'Lebanon', ['LC'] = 'Saint Lucia', ['LI'] = 'Liechtenstein', ['LK'] = 'Sri Lanka', ['LR'] = 'Liberia', ['LS'] = 'Lesotho', ['LT'] = 'Lithuania', ['LU'] = 'Luxembourg', ['LV'] = 'Latvia', ['LY'] = 'Libyan Arab Jamahiriya', ['MA'] = 'Morocco', ['MC'] = 'Monaco', ['MD'] = 'Moldova', ['ME'] = 'Montenegro', ['MG'] = 'Madagascar', ['MK'] = 'Macedonia', ['ML'] = 'Mali', ['MM'] = 'Myanmar', ['MN'] = 'Mongolia', ['MO'] = 'Macao', ['MP'] = 'Northern Mariana Islands', ['MR'] = 'Mauritania', ['MS'] = 'Montserrat', ['MT'] = 'Malta', ['MU'] = 'Mauritius', ['MV'] = 'Maldives', ['MW'] = 'Malawi', ['MX'] = 'Mexico', ['MY'] = 'Malaysia', ['MZ'] = 'Mozambique', ['NA'] = 'Namibia', ['NE'] = 'Niger', ['NG'] = 'Nigeria', ['NI'] = 'Nicaragua', ['NL'] = 'Netherlands', ['NO'] = 'Norway', ['NP'] = 'Nepal', ['NR'] = 'Nauru', ['NZ'] = 'New Zealand', ['OM'] = 'Oman', ['PA'] = 'Panama', ['PE'] = 'Peru', ['PG'] = 'Papua New Guinea', ['PH'] = 'Philippines', ['PK'] = 'Pakistan', ['PL'] = 'Poland', ['PT'] = 'Portugal', ['PW'] = 'Palau', ['PY'] = 'Paraguay', ['QA'] = 'Qatar', ['RO'] = 'Romania', ['RS'] = 'Serbia', ['RU'] = 'Russian Federation', ['RW'] = 'Rwanda', ['SA'] = 'Saudi Arabia', ['SB'] = 'Solomon Islands', ['SC'] = 'Seychelles', ['SD'] = 'Sudan', ['SE'] = 'Sweden', ['SG'] = 'Singapore', ['SH'] = 'Saint Helena', ['SI'] = 'Slovenia', ['SK'] = 'Slovakia', ['SL'] = 'Sierra Leone', ['SM'] = 'San Marino', ['SN'] = 'Senegal', ['SO'] = 'Somalia', ['SR'] = 'Suriname', ['ST'] = 'Sao Tome and Principe', ['SV'] = 'Salvador', ['SX'] = 'Sint Maarten (Dutch part)', ['SY'] = 'Syrian Arab Republic', ['SZ'] = 'Swaziland', ['TC'] = 'Turks and Caicos Islands', ['TD'] = 'Chad', ['TG'] = 'Togo', ['TH'] = 'Thailand', ['TJ'] = 'Tajikistan', ['TL'] = 'Timor?Leste', ['TM'] = 'Turkmenistan', ['TN'] = 'Tunisia', ['TO'] = 'Tonga', ['TR'] = 'Turkey', ['TT'] = 'Trinidad and Tobago', ['TV'] = 'Tuvalu', ['TW'] = 'Taiwan', ['TZ'] = 'Tanzania', ['UA'] = 'Ukraine', ['UG'] = 'Uganda', ['US'] = 'United States of America', ['UY'] = 'Uruguay', ['UZ'] = 'Uzbekistan', ['VA'] = 'Holy See', ['VC'] = 'Saint Vincent', ['VE'] = 'Venezuela', ['VG'] = 'Virgin Islands', ['VN'] = 'Viet Nam', ['VU'] = 'Vanuatu', ['WS'] = 'Samoa', ['YE'] = 'Yemen', ['ZA'] = 'South Africa', ['ZM'] = 'Zambia', ['ZW'] = 'Zimbabwe' } ------------------------------------------------------------------------------------------------------------------------- function getPlayerLocation(player) local ip = getPlayerIP(player) local countryCode = exports["admin"]:getPlayerCountry(player) local country = "San Andreas" if countryCode and countryNames[countryCode] then country = countryNames[countryCode] end setElementData(player, "Country", country) function displayPlayerLocation( resp, errno, player) if errno == 0 then local data = fromJSON("[".. resp .. "]") local status = data["status"] or "fail" if status == "success" then for k,v in ipairs(getElementsByType"player") do if v ~= player then outputChatBox("✶ Joined: #FFFFFF"..getPlayerName(player).."#FF6464 ("..data["city"]..", ".. data["country"]..") joined the server.", v, 255, 100, 100, true) end end else outputDebugString("Cannot retrieve network details") for k,v in ipairs(getElementsByType"player") do if v ~= player then outputChatBox("✶ Joined: #FFFFFF"..getPlayerName(player).."#FF6464 ("..country..") joined the server.", v, 255, 100, 100, true) end end end else outputDebugString("Error @fetchRemote, ERRNO: " .. errno) end end fetchRemote("http://ip-api.com/json/" .. ip, displayPlayerLocation, "", false, player) end ------------------------------------------------------------------------------------------------------------------------- function OnPlayerJoin () getPlayerLocation(source) end addEventHandler("onPlayerJoin", getRootElement(), OnPlayerJoin)
-
If you want it to work only that vehicle then yes, what you did is correct. But the 'addEventhandler' must be after the function in your case. In this^ example it is inside a function, but the addEventHandler is not bound to the same function it is inside of - it's for another function.
-
vehicle = createVehicle ( 429, 1, 2, 3, 0, 0, 0) function fail (player) if player and getElementType ( player ) == 'player' then setElementData(player, "mission", false) setTimer(setVehicleLocked, 350, 1, vehicle, false) outputChatBox("test") end end addEventHandler ( "onVehicleExplode", root, fail ) addEventHandler sits after the whole function. And you need to replace 'vehicle' with 'root' in the addEventHandler line.
-
Here's what I tried but for some reason it doesn't show the chatbox message, yet there are no errors in debug. local cache = {} -- { [IP] = {city = table.geoplugin_city} } -- checks cache for loc data, request via api if not available -- sets element data asap function checkIP(player) if player and isElement(player) then local IP = getPlayerIP(player) if cache[IP] then -- force resync by removing --removeElementData(player, "city") setElementData(player, "city", cache[IP].city) elseif split(IP,'.')[1] == "192" or split(IP,'.')[1] == "172" or split(IP,'.')[1] == "10" or split(IP,'.')[1] == "127" then -- fetch our own IP for local adresses fetchRemote('http://www.geoplugin.net/json.gp', receiveIPdata, '', false, IP, getPlayerName(player)) else fetchRemote('http://www.geoplugin.net/json.gp?ip=' .. IP, receiveIPdata, '', false, IP, getPlayerName(player)) end end end function receiveIPdata(json, err, IP, nick) -- check for fetchRemote errors if err ~= 0 then outputDebugString( "geoloc: receiveIPdata fetch failed, err=" .. tostring(err) .. ', json=' .. tostring(json) .. ', IP=' .. tostring(IP) .. ', nick=' .. tostring(nick)) return end --check for parsing errors local table = fromJSON('['..json..']') if not (type(table) == 'table' and type(table.geoplugin_city) == 'string' and #table.geoplugin_city > 0) then outputDebugString( "geoloc: receiveIPdata parse failed, err=" .. tostring(err) .. ', json=' .. tostring(json) .. ', IP=' .. tostring(IP) .. ', nick=' .. tostring(nick)) return end -- store data in cache cache[IP] = {city = table.geoplugin_city} -- if player is online, set element data local player = getPlayerFromName(nick) if player then setElementData(player, "city", table.geoplugin_city) end end function getCity(name) checkIP(getPlayerFromName(name)) end addEventHandler("onPlayerConnect", root, getCity) function onPlayerJoin() local city = getElementData(source, "city") if city then outputChatBox("#FFFFFF"..getPlayerName(source).."#FFFFFF joined from #FEFE22"..city..".", root, 255, 100, 100, true) end end addEventHandler("onPlayerJoin", root, onPlayerJoin) -- exports function getPlayerCity(player) return player and isElement(player) and getIPCity(getPlayerIP(player)) end function getIPCity(IP) return cache[IP] and cache[IP].city or false end
-
Found example here, gonna try: https://github.com/JarnoVgr/Mr.Green-MTA-Resources/blob/master/resources/[gameplay]/geoloc/geoloc.lua
-
I found this website: http://www.geoplugin.com/ I know how to get player ip but I have really no idea how to use fetchRemote to get the city part for each newly joined player's ip location. Never had to use fetchRemote before so am in the dark now...wiki didn't help much either
-
Thanks. I took a look into it but it seems that all of the Russian cities are inside their own database file... So i don't think i can edit that Anything else you can think of?
-
The country is done already, but I don't know how to add his city too.
-
Ah, you didn't understand me. Not the game cities, real cities. Example: '[SiK]Megas (Sofia, Bulgaria) joined the server'
-
We all know that it's easy to display from which country a player joins...but can somebody share the code which also displays from which city the player joins? I've seen it in some servers and all I know is that they get the information from a geolocation website. But I got no idea how to make that myself, so if anyone has it or wants to make it (if not too hard ofc), please help me out