Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. Citizen

    solved

    Hehe, I never test them because I too lazy to start a server, but I should test it in ideone, I know But this time my function has been tested and is workign fine now: https://ideone.com/q3wLNF By the way, now you didn't apply the Solidsnake's fix right ? The only reason for that bug is that the following lisne is returning false: local repPoints = getElementData(player, "Reputation.points") or 0 So I think you didn't replaced killer by player as Solidsnake told you. Try this again but with an output like this: function updateReputationName( player ) local repPoints = getElementData(player, "Reputation.points") or 0 local newRepName = getReputationName( repPoints ) outputChatBox( repPoints.." => "..newRepName) setElementData(player, "Reputation.status", newRepName) end And tell us what's written in the chabox when you kill someone. I'm also pretty sure you aren't using /debugscript 3 to be able to see client side errors. You won't see them in the server's console. If it's still not working show us the code you have now since we did a lot of modifications. I want to see if you did them correctly.
  2. It's just a warning because you want them to start follow or aim a bot (idk since you didn't say which line it was) but you never told them to stop doing that action where you should. By the way they are doing the action you want already, so I guess there is no problem. Just read your script again step by step and you will maybe find where/when you should use removeEventHandler.
  3. Citizen

    solved

    I also rechecked my function getReputationName which was totally wrong. Run this code and see the result https://ideone.com/zLMTY5 So after you did the Solidsnake's fix, change your code to be like this: local reputations = { {-1095 , "demon" }, {-795 , "evil" }, {-10 , "bad2" }, {-5 , "bad1" }, {0 , "normal" }, {5 , "good1" }, {10 , "good2" }, {795 , "good3" }, {1095 , "hero" } } function getReputationName( points ) local _, data = next( reputations ) local result = data[2] for k, repdata in ipairs ( reputations ) do if repdata[1] <= points then result = repdata[2] else break end end return result end
  4. Bah tu ouvres les fichiers de la resource race et tu modifies les commandes de façon à ce que les modos puisse utiliser ces commandes là.
  5. Il te faut modifier le code de ces fonctions. L'acl est bon donc je ne sais pas, essaye de te mettre que dans le groupe Admin et essaye à nouveau. (N'oublie pas de te login) Oui je veux bien, parce que là c'est pas possible de dire ce qu'il ne va pas. Il doit y en avoir plein dans le community center: https://community.multitheftauto.com/in ... =resources
  6. Well idk much how sqlite works internally and how it is bound in the MTA Server code, but I think the file can't be corrupted if MTA developpers did it correctly using a detached thread so if the main thread (the mta server) crash, then the detached thread will still work untill the query he got has been done correctly. I can't verify it right now but backups aren't needed (or you won't use them to rollback the db if it got corrupted somehow because it will likely never happen). But if you need backups for another reason, then I would probably do one every 4 or 8 hours (so 8 or 4 backups a day). The LIMIT keyword in a SQL query let you specify how much rows you want to get at most. So if you want at most 1 row, then the query will looks like this: "SELECT * FROM user_list WHERE username = ? LIMIT 1" But strings must be surrounded with single quotes to be sure the query won't think it's a column or an internal variable name: "SELECT * FROM user_list WHERE username = '?' LIMIT 1" No problem, I wouldn't do it if you didn't make some work on your side before asking and you seems really interested in SQL stuff so yeah, it was a pleasure
  7. Well, you didn't really looked at the wiki functions list: getPedFightingStyle setPedFightingStyle And here are two possible solutions: function forceNormalFightStyle() for k, player in ipairs ( getElementsByType("player") ) do if getPedFightingStyle( player ) ~= 4 then setPedFightingStyle( player, 4 ) end end end setTimer(forceNormalFightStyle, 1000, 0) -- or addEventHandler("onPlayerJoin", root, function() local timer = setTimer( setPedFightingStyle, 1000, 0, source, 4 ) setElementData( source, "fightStyleTimer", timer) end) addEventHandler("onPlayerQuit", root, function() local timer = getElementData( source, "fightStyleTimer") if timer and isTimer( timer ) then killTimer( timer ) end end) I really don't know which one is the best (talking about performance). By the way, it's tiny enough to not really care of it.
  8. It is working, check the file you are working on is in the meta.xml, that it's a server sided script and that you are restarting the resource to apply changes. If it's not working, be sure you copied it correctly and there are no errors in the console.
  9. You gave him a not working skeleton so yeah, I just said what was missing in it. But ofc he will do the rest.
  10. If you had read what WhoAmI and I said, it's obviously the WhoAmI's code.
  11. There is no need to use multiple databases for a single gamemode. The queries would be harder than the queries you will perform on a single database. Using more that one database is for really specific cases. So I really recommend you to use one database (even if you have 30+ tables in it) Well not really but for me, if a table has more than 15 columns, it's almost sure that there are some columns that can be in another table. Example: you have a table name "players" in which you have the following columns: id|login|password|language|weaponSlot0|ammoSlot0|weaponSlot1|ammoSlot1| ... |weaponSlot12|ammoSlot12 So there are 30 columns You can easily simplify this by using another table you can call "weapons" or "weaponsInventory" in which you will get these columns: id | playerid | weapon | ammos where playerid will be a foreign key of the id column from the "players" table example of entries: Table: players | id | login | password | language | |-----|-------|----------|----------| | 1 | duff | thepass | en | Table: weapons | id | playerid | weapon | ammos | |-----|----------|--------|-------| | 1 | 1 | 5 | 1 | | 2 | 1 | 35 | 130 | It means that the playerid 1 (duff in the player table) has 1 baseball bat and a rocket launcher with 130 rockets. myeah not a bad idea, but do not use to much triggers to get the players datas on the client-side. I don't really know about the size of sqlite database files but you will need a lot of datas to go over 500 MB or 1GB. So you don't have to worry about it unless you are storing it on 2GB harddrive Do not get all columns when you only need the datas in some specific columns (To get the money: "SELECT * FROM players WHERE login='duff';" and then only get the money or: "SELECT money FROM players WHERE login='duff';") NEVER store the original passwords in the database, hash them (use sha256 for decent security and you can also "salt" it. More infos about salted hashes here). And when the players try to login, you will hash the password he sent and then check the hash in the database. If both are the same, it means that the password he just sent is the same as the one in the database (inserted when he registered). You should never get the password from the database into your lua script. Let the SQL queries check it for you using this simple query: "SELECT id, login, language FROM players WHERE login='duff' AND password='thepass';" It will return the rows with only the value of id, login and laguage columns (don't use * because you don't want to get the password) where the login is duff and thepass is thepass. If it returns you 1 row, then it means that it (SQLite in your case) found a row matching the WHERE closure so the login and password are good. If it returns an empty result, then it means that the login or password aren't correct. Always put an id column in all tables. It should be a PRIMARY KEY (the column that can be trusted to identify an entry/row. It should never be changed !). And enable the AUTO_INCREMENT on that column. This way, the id will be unique and will be automatically seted when using INSERT statement (so do not specify it when using the INSERT statement). You can add a simple INDEX on columns you will often use in WHERE closure (on tables that will get really big like the players table). In the example above, it will be a good idea to set an INDEX on the login column. You can set a UNIQUE index. It's an index that will drop queries that will try to insert a new row with a value in that column already used in another row. - Citizen [ Ex player of a random server ] (yeah no one care )
  12. Where is the Mr.Pres[T]ege's code in this script ??? I don't see it ! One more time, you have to use this and a variable to change the alpha:
  13. We won't help you to steal client stuff from other servers.
  14. Citizen

    GUI Bind

    This part of the code: Must be placed after the gui creation as Solidsnake wanted you to do. And when it's not working, please give us the errors poping on the screen using /debugscript 3
  15. First say "hi" and explain what's the problem. We aren't robots nor your slaves. Respect these simple and obvious rules if you want to get more chances to be helped by one of us. This is actually how it looked like for me: *opens the door* *throw the code in the room* Fix it for me ! *close the door*
  16. Use playSound onClientPlayerVehicleEnter You will also need: onClientPlayerVehicleExit setTimer and maybe getElementModel because the exit animation doesn't last the same for all vehicles (and you probably want to use different door sounds (bus, car, planes, ...)
  17. Where is the reset of iCallLast ?? @3B00DG4MER: Show us the code to see if you completed it correctly.
  18. First, he didn't insult you or wasn't a disrespectful person. He was just totally shocked someone wrote this awful script and pretend it's a good solution. I was also shocked when I saw your script and thought the same ("this guy is crazy"). And I'm even more shocked when you said it won't lag. It won't lag on the client side if the player has a pretty good computer and won't lag on the server side if there is not a lot of players on the server. But let's take an example okay ? So imagine you can manage to get 50 players on your server and all have 30 fps. Then the server part will take 1 500 executions per second right in the face (3 000 if they all have 60fps). And for what purpose ? Just to update an element data to set the current player team name. Do you still think it won't lag and still a good solution ? (I hope not anymore) And don't forget that there is the rest of the gamemode to run and others resources as well.
  19. Because he owner of SAUR server in The server there is that script,i saw it . Lol so because someone already did it for his own server, then you think he will give it for you for free ? Just by asking ? Solidsnake obviously won't give it to anyone for free (and he won't sell it too). It's part of his gamemode on which he worked hard. And if he would like to give it to you, then you won't be able to make it work since it's obviously part of the whole gamemode and won't work "out of the box" without modifications you won't be able to do. That being said, have a nice day. (Ps: You are supposed to be a scripter, so just script it yourself). Best regards, Citizen
  20. Ok, I understood the code even if it's pretty dirty, replace the aimForTarget function: function aimForTarget() if (#guards == 0) then removeEventHandler('onClientRender', root, aimForTarget) addEventHandler('onClientPreRender', root, followPlayer) return end if (not isElement(target) or isPedDead(target)) then for index, guard in pairs(guards) do if (isElement(guard)) then setPedControlState(guard, 'fire', false) end end removeEventHandler('onClientRender', root, aimForTarget) addEventHandler('onClientPreRender', root, followPlayer) return end local ax, ay, az = getElementPosition(target) local x, y, z = getElementPosition(localPlayer) local bx, by, bz = getPedBonePosition(target, 1) for index, guard in pairs(guards) do local tx, ty, tz = getElementPosition(guard) local targetDis = getDistanceBetweenPoints3D (tx, ty, tz, ax, ay, az) local weapon = getPedWeaponSlot (guard) if (targetDis > 20) and (weapon == 30) then if (not isElement(guard) or isPedDead(guard)) then table.remove(guards, guard) return end setPedRotation(guard, findRotation(tx, ty, x, y)) setPedAimTarget(guard, bx, by, bz) setPedControlState(guard, 'fire', true) else setPedRotation (guard, findRotation(tx, ty, ax, ay)) setPedAimTarget(guard, bx, by, bz, false) setPedControlState(guard, 'fire', false) end if (targetDis > 15) and (weapon == 22) then if (not isElement(guard) or isPedDead(guard)) then table.remove(guards, guard) return end setPedRotation(guard, findRotation(tx, ty, x, y)) setPedAimTarget(guard, bx, by, bz) setPedControlState(guard, 'fire', true) else setPedRotation (guard, findRotation(tx, ty, ax, ay)) setPedAimTarget(guard, bx, by, bz, false) setPedControlState(guard, 'fire', false) end end end (edited line 26 and 36)
  21. If you used the guieditor resource, you should set the parents relative to the screen. (Right click somewhere on the screen (but not on a gui element) and click on Rel/Abs parent or something.) This way it will generate the gui code using relative values. guiGetScreenSize is only needed to set the rel values in absolute one right before you use dx functions (they only support/accept absolute values). For the gui elements, there is no need to use that function since they accept both values but you have to specify that functions if you are sending him absolute or relative values by using the boolean argument "relative" (check the wiki pages to know which one is the "relative" arguement). So the Dealman's example is wrong because he uses guiGetScreenSize to tansform relative values into absolute one but still saying to the gui function the values he is sending to it are relative ones. So check the next examples (fixing the Dealman's post): local screenX, screenY = guiGetScreenSize() local exampleWindow = guiCreateWindow(screenX*(400/1360), screenY*(600/768), screenX*(150/1360), screenY*(300/768), "Example", false) is the same as: local exampleWindow = guiCreateWindow( 400/1360, 600/768, 150/1360, 300/768, "Example", true) Both examples will be placed correctly on all resolutions.
  22. Try this: Server: function make_db () executeSQLQuery ("CREATE TABLE IF NOT EXISTS dealercars (id NUMERIC, owner TEXT, model NUMERIC, name TEXT, health NUMERIC, paintjob NUMERIC, color NUMERIC, upgrades NUMERIC)") end addEventHandler("onResourceStart", resourceRoot, make_db) local dealerMarker1 = createMarker(2131.75, -1148.138671875, 23.406946182251, "cylinder", 2, 0, 255, 0, 255) createBlipAttachedTo(dealerMarker1, 55, 2, 0, 0, 0, 0, 0, 300) function open_dealer_server ( hitElement ) if source == dealerMarker1 and getElementType( hitElement ) == "player" then triggerClientEvent(hitElement, "open_dealer_wdw", hitElement) end end addEventHandler("onMarkerHit", root, open_dealer_server) function buy_car_from_dealer (model, price) if getPlayerMoney(client) >= price then local vehicles = executeSQLQuery("SELECT id FROM dealercars") local carid = 1 for k, row in ipairs ( vehicles ) do if row.id > carid then carid = row.id end end local account = getAccountName(getPlayerAccount(client)) local modela = getVehicleModelFromName(model) local x, y, z = getElementPosition( client ) local veh = createVehicle( modela, x, y, z+1 ) takePlayerMoney(client, money) setElementID( veh, carid ) local carbought = executeSQLQuery( "INSERT INTO dealercars(id,owner,model,name,health,paintjob,color,upgrades) VALUES(?,?,?,?,?,?,?,?)", carid, tostring(account), modela, tostring(model), 1000, 0, 0, 0 ) outputChatBox("Congratulations you've bought a "..model.." for $"..money, client, 0, 255, 0) else outputChatBox("You don't have enough money", client, 255, 0, 0) end end addEvent("buy_dealer_car", true) addEventHandler("buy_dealer_car", root, buy_car_from_dealer) ---------------------------------------------- --------------- Spawner Panel ---------------- ---------------------------------------------- function open_spawner_pla () triggerClientEvent(client, "open_spawner_wdw", root) end function list_owned_cars_server () local playerAcc = getAccountName(getPlayerAccount(player)) local carlmao = executeSQLQuery("SELECT * FROM dealercars WHERE owner=?", playerAcc) if carlmao and type(carlmao) == "table" and #carlmao > 0 then triggerClientEvent(client, "list_owned_cars", root, carlmao) end end addEvent("list_owned_cars_S", true) addEventHandler("list_owned_cars_S", root, list_owned_cars_server) function spawn_car_pleaseD ( vehID ) local gayowner = getAccountName(getPlayerAccount(client)) local carModel = getVehicleModelFromName(carName) local x,y,z = getElementPosition(client) local veh if vehID then veh = getElementByID( vehID ) if veh and getElementType( veh ) == "vehicle" then fixVehicle( veh ) end else veh = createVehicle(carModel, x, y, z) setElementID( veh, vehID ) setElementData(veh, "owner", tostring(gayowner)) end setTimer(warpPedIntoVehicle, 100, 1, client, veh) end addEvent("spawn_dealer_car", true) addEventHandler("spawn_dealer_car", root, spawn_car_pleaseD) function destroy_car_pleaseD ( ownerName ) local gayownerAcc = getAccountName(getPlayerAccount(ownerName)) local pedCar = getPedOccupiedVehicle(ownerName) if pedCar then if getElementData(pedCar, "owner") == gayownerAcc then local currentCar = getPedOccupiedVehicle(ownerName) -- SQL query (UPDATE) here to update the vehicle datas in the database destroyElement(currentCar) else outputChatBox("You can't park a car you don't own", ownerName, 255, 0, 0) end else outputChatBox("You aren't in a vehicle", ownerName, 255, 0, 0) end end addEvent("destroy_dealer_car", true) addEventHandler("destroy_dealer_car", root, destroy_car_pleaseD) addEvent ("lock", true) addEventHandler ("lock", root, function (veh) local veh = getPedOccupiedVehicle (localPlayer) setVehicleLocked (veh, true) end) addEvent ("unlock", true) addEventHandler ("unlock", root, function (veh) local veh = getPedOccupiedVehicle (localPlayer) setVehicleLocked (veh, false) end) Line 88, make a query to update the database Client: dealerwdw = guiCreateWindow(0.19, 0.19, 0.57, 0.70, "", true) guiWindowSetSizable(dealerwdw, false) dealerwdwgrid = guiCreateGridList(0.02, 0.05, 0.97, 0.83, true, dealerwdw) guiGridListAddColumn(dealerwdwgrid, "Car", 0.5) guiGridListAddColumn(dealerwdwgrid, "Price", 0.5) dealerwdwclosebtn = guiCreateButton(0.01, 0.88, 0.34, 0.09, "Close", true, dealerwdw) guiSetProperty(dealerwdwclosebtn, "NormalTextColour", "FFAAAAAA") dealerwdwbuybtn = guiCreateButton(0.65, 0.88, 0.34, 0.09, "Buy", true, dealerwdw) guiSetProperty(dealerwdwbuybtn, "NormalTextColour", "FFAAAAAA") guiSetVisible(dealerwdw, false) function open_dealer_panel () if guiGetVisible(dealerwdw) == false then list_cars() guiSetVisible(dealerwdw, true) showCursor(true) end end addEvent("open_dealer_wdw", true) addEventHandler("open_dealer_wdw", root, open_dealer_panel) DealerVehicles = { {"Admiral", 50000}, {"Comet", 1000000}, {"Infernus", 3000000}, {"Bullet", 1500000}, {"Sultan", 1000000}, {"Huntley", 750000}, {"Sabre", 1000000} } function list_cars () guiGridListClear(dealerwdwgrid) for i,v in ipairs(DealerVehicles) do local row = guiGridListAddRow(dealerwdwgrid) guiGridListSetItemText(dealerwdwgrid, row, 1, v[1], false, false) guiGridListSetItemText(dealerwdwgrid, row, 2, v[2], false, false) end end function dealer_panel_clicked () if source == dealerwdwclosebtn and guiGetVisible(dealerwdw) == true then guiSetVisible(dealerwdw, false) showCursor(false) guiGridListClear(dealerwdwgrid) end end addEventHandler("onClientGUIClick", dealerwdw, dealer_panel_clicked) function dealer_panel_buy (player) if source == dealerwdwbuybtn then local row = guiGridListGetSelectedItem(dealerwdwgrid) local model = guiGridListGetItemText(dealerwdwgrid, row, 1) local price = guiGridListGetItemText(dealerwdwgrid, row, 2) triggerServerEvent("buy_dealer_car", localPlayer, model, tonumber(price)) end end addEventHandler("onClientGUIClick", dealerwdw, dealer_panel_buy) ---------------------------------------------- --------------- Spawner Panel ---------------- ---------------------------------------------- spawncarwdw = guiCreateWindow(0.71, 0.31, 0.27, 0.52, "Spawn vehicle", true) guiWindowSetSizable(spawncarwdw, false) guiSetAlpha(spawncarwdw, 1.00) spawncarwdwgrid = guiCreateGridList(0.05, 0.35, 0.92, 0.60, true, spawncarwdw) guiGridListAddColumn(spawncarwdwgrid, "Car", 0.5) guiGridListAddColumn(spawncarwdwgrid, "Health", 0.3) spawncarwdwlockbtn = guiCreateButton(0.49, 0.22, 0.37, 0.10, "lock", true, spawncarwdw) guiSetProperty(spawncarwdwclosebtn, "NormalTextColour", "FFFD0000") spawncarwdrefwdw = guiCreateButton(0.05, 0.22, 0.33, 0.09, "Refresh List", true, spawncarwdw) guiSetProperty(spawncarwdrefwdw, "NormalTextColour", "FF72F805") spawncarwdwspwnwdw = guiCreateButton(0.49, 0.08, 0.37, 0.10, "Spawn", true, spawncarwdw) guiSetProperty(spawncarwdwspwnwdw, "NormalTextColour", "FF72F805") spawncarwdwparkbtn = guiCreateButton(0.05, 0.08, 0.32, 0.11, "Hide", true, spawncarwdw) guiSetProperty(spawncarwdwparkbtn, "NormalTextColour", "FFFE0000") guiSetVisible(spawncarwdw, false) function open_spawner_panel () if guiGetVisible(spawncarwdw) == false then triggerServerEvent("list_owned_cars_S", localPlayer) guiSetVisible(spawncarwdw, true) showCursor(true) elseif guiGetVisible(spawncarwdw) == true then guiSetVisible(spawncarwdw, false) showCursor(false) end end bindKey("f3", "down", open_spawner_pla) function vehicle_spawner_panel () if source == spawncarwdwlockbtn and guiGetText (spawncarwdwlockbtn) == "lock" then triggerServerEvent ("lock", localPlayer) guiSetText (spawncarwdwlockbtn, "Unlock") end if source == spawncarwdwlockbtn and guiGetText (spawncarwdwlockbtn) == "Unlock" then triggerServerEvent ("unlock", localPlayer) guiSetText (spawncarwdwlockbtn, "lock") end if source == spawncarwdrefwdw then triggerServerEvent("list_owned_cars_S", localPlayer) end if source == spawncarwdwspwnwdw then local row = guiGridListGetSelectedItem(spawncarwdwgrid) local vehID = guiGridListGetItemData(spawncarwdwgrid, row, 1) triggerServerEvent("spawn_dealer_car", localPlayer, vehID) end if source == spawncarwdwparkbtn then triggerServerEvent("destroy_dealer_car", localPlayer) end end addEventHandler("onClientGUIClick", spawncarwdw, vehicle_spawner_panel) function list_cars_you_own ( vehicles ) guiGridListClear(spawncarwdwgrid) for k, veh in ipairs ( vehicles ) do local row = guiGridListAddRow(spawncarwdwgrid) guiGridListSetItemText(spawncarwdwgrid, row, 1, tostring(veh.name), false, false) guiGridListSetItemData(spawncarwdwgrid, row, 1, veh.id) local spawnedVeh = getElementByID( veh.id ) local vehHealth = veh.health if spawnedVeh and getElementType( spawnedVeh ) == "vehicle" then vehHealth = getElementHealth( spawnedVeh ) end guiGridListSetItemText(spawncarwdwgrid, row, 2, tonumber(vehHealth), false, false) end end addEvent("list_owned_cars", true) addEventHandler("list_owned_cars", root, list_cars_you_own) Dunno if it will work immediatly, so please provide errors from the server but also from the client (/debugscript 3) (Wasted some time to indent that code correctly. So please be sure your code is indented using tabs the next time you post some code.)
  23. Try this just to be sure the function is still not working with trains: local loco = createVehicle ( 537, 1467, -1532, 10 ) local parent = loco for k=1, 5 do local carriage = createVehicle ( 590, 1467+(k*18), -1532, 10 ) attachTrailerToVehicle( carriage, parent ) parent = carriage end
×
×
  • Create New...