Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. Not complete there is one at line 42 too. gghvc: replace thePlayer by source on line 42: givePlayerMoney ( thePlayer, 1700 ) and 54: givePlayerMoney ( thePlayer, 1700 ) and stop copying and pasting without knowing what you are actually doing.
  2. Tu ne peux pas te lancer dans un tel système sans avoir vu les bases: https://wiki.multitheftauto.com/wiki/FR/ ... grammation Ensuite, il te faudra utiliser les fonctions suivantes: getPlayerAccount --pour récupérer le compte d'un joueur isGuestAccount --pour vérifier si un compte est un compte visiteur (s'il ne s'est pas login en utilisant /login, il doit d'abord faire un /register pour se créer un compte sur le serveur) setAccountData -- Pour enregistrer une donnée (3ère argument) sous un nom (2ème argument) pour un compte (1ère arguement) -- Ces données sont enregistrés dans le fichier internal.db (il me semble) dans le dossier deathmatch. Tu peux utiliser [url=http://sourceforge.net/projects/sqlitebrowser/]http://sourceforge.net/projects/sqlitebrowser/[/url] pour explorer la db. getAccountData -- Pour récupérer une donnée sous un nom (2ème argument) pour un compte (1er argument) Regarde l'exemple du wiki pour le setAccountData c'est EXACTEMENT ce que tu es censé faire, sauf que c'est pas l'argent que tu vas sauvegarder, mais 4 données: la position (X, Y, Z) et la rotation (RZ). Donc tu devras faire 4 setAccountData dans le onPlayerQuit et 4 getAccountData dans le onPlayerLogin. Il te faudra aussi les fonctions suivantes pour les positions/rotations: getElementPosition --pour récupérer la position d'un élément (X, Y, Z) getElementRotation -- pour récupérer la rotation d'un élément (RX, RY, RZ) setElementPosition --pour téléporter un élément à une certaine position (X, Y, Z) setElementRotation --pour changer la rotation d'un élément (RX, RY, RZ) Pour le cas d'un joueur, on d'en fou des rotations RX et RY, pas besoin de les sauvegarder car ça sera toujours 0 (RX = pencher en avant ou en arrière, RY = pencher sur la gauche ou sur la droite). Je te souhaite un bon apprentissage. Cordialement, Citizen
  3. You can't do that since guiGridListGetSelectedItem returns two values. You have to store its result using a variable and then send it in guiGridListGetItemText. I guess it's clear enough to not write you the soltution.
  4. Wasn't my function btw.
  5. function open() local helpwindow = GUIEditor.window[1] if (guiGetVisible (helpwindow) == false) then guiSetVisible(helpwindow, true) showCursor(true) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(helpwindow,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(helpwindow,x,y,false) centerWindow(helpwindow) elseif (guiGetVisible (helpwindow) == true) then guiSetVisible(helpwindow, false) showCursor(false) end end bindKey ("F1", "down", open) Learn to use the right variables ... Note: I just added the line 2
  6. Well, it's called database optimisation. A well made database and well constructed queries will reduce the CPU load a lot. For example, even your query can be improuved: "SELECT COUNT(*) FROM car WHERE owner='"..account.."'" This way, sqlite won't get the values in each column if there is an entry that match the WHERE clause. Yeah because in your script, you don't care about what are the values in each columns of the car that the query will potentially find, you just want to check the number of entries/car it will find for that owner. http://www.w3schools.com/sql/sql_func_count.asp
  7. When looking for something for mta: 1 - Ask google first 2 - then check the wiki/resource center 3 - Use the search feature on this forum 4 - Ask to us (the forum) OH and what a luck !! I found it in the first step ! http://lmgtfy.com/?q=mta+1st+person+mod
  8. Did you even read what I just said ? Did you check the wiki page of dbQuery and dbPoll ?Don't you remember how we were getting the result(s) from database with dbQuery and dbPoll ? dbPoll is giving you a the result(s) as a table not dbQuery. Please do an effort like you always did.
  9. If that code work, why using InOutQuad as easing type ? linear would be better imo. Also, why rotating the player on X axis ? The character will just do front flips You had to rotatate him on the Z axis actually It's a good practice to use interpolateBetween in onClientRender but you had to use it with getTickCount to control the execution speed. The more FPS you will get, the faster your character will spin. A simple setTimer would do the trick.
  10. replace index_name by whatever you want. It's a name that will identify the index you are creating so you will be able to delete that index using that name if you need to allow multiple cars with the same owner later. Be carefull, there are multiple index types (index are just constraints): http://www.w3schools.com/sql/sql_constraints.asp So usually, you will set a PRIMARY KEY on the id column (not the vehmodel, the id of the entry/line in the table) and add the AUTO_INCREMENT on that same column. It will just set a new id for you, so no need to set the id when using ur INSERT query. And if you need to add a constraint on a column to be sure you won't store two times a same value on that column in that table, just add a UNIQUE index (UNIQUE is the type of that index). Yeah it will ! The database won't insert it in your table and will return an errorCode and errorText (but the error code is enough) According to this page, the error code returned will probably be 19 if the player already owns a car: http://www.sqlite.org/c3ref/c_abort.html Well we (Solidsnake and myself) already show you how to do a query with dbQuery and getting the result with dbPoll: viewtopic.php?f=91&t=72059#p667863 Just replace line 2 by: local result, affectedRowsOrErrCode = dbPoll( qh, -1 ) If affectedRowsOrErrCode is equal to 1, then it means that the row has been inserted (number of affected rows). But if it is equal to 19, then it means that it's the error code returned by sqlite (since you didn't try to insert 19 rows ). See the 2nd example of the dbPoll wiki page.
  11. The players can only own one car ? If yes, then I would suggest you to set a UNIQUE index on the owner column. This way, your query will fail if you want to insert an entry in this table with an owner that is already in the table (so it means that he already owns a car). But dbExec doesn't tell you if the query has failed or not, you will have to use dbQuery and then dbPoll (the last one will return you the error code return by the database if any). To create an UNIQUE index on a table column: CREATE INDEX index_name ON table_name (column_name);
  12. Haha, you didn't help him at all. WhoAmI helped him. Your code wil do this: When a vehicle explode: Creates another one and immediatly delete this new car and it will be that fast that you won't see that new car and leaving the burned car on the road.
  13. No, more like this: (I modified a bit the setPlayerTeam from WhoAmI) _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) if not thePlayer or not theTeam then return false end local oldTeam = getPlayerTeam( thePlayer ) triggerEvent ( "onPlayerChangeTeam", thePlayer, theTeam, oldTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end addEventHandler ( "onPlayerChangeTeam", root, function ( theNewTeam, theOldTeam ) local teamName = getTeamName( theNewTeam ) if teamName ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end )
  14. Nice script, I would just add the local in front of theVehicle at line 13. Also, I would set thePlayer as source of the event, and just sending theTeam as parameter of the function.
  15. Wanted to see the how you were showing the fuel on screen actually.
  16. Can we see how you did that ? (only what you added ofc)
  17. As you can see, he is already doing it ... All the functions you need are: getElementPosition dxDrawImageSection Then you just have to do some math to calculate the player position on the image according to his gta world position.
  18. Yeah, then why not trying yourself ? We will be there if you are getting stuck. It's better to help someone trying to fix his problems than someone asking for others to do it for him.
  19. OMG ! I can't believe you just made a global to fix stuff on server side :facepalm: What if player2 uses the /sell command right after player1 ? Yeah, the marker of player1 will never be destroyed and will stay untill the server restart. Still thinking it was a good solution ? I don't think so ... And btw why did you do x + 0 and y + 0 ? Also the gui will be shown on every markers created by that same resource ... Here's a real solution: Server: function consoleCreateMarker ( thePlayer, commandName ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local theMarker = createMarker ( x, y, z - 1, "cylinder", 1.5, 255, 0, 0, 170 ) if ( theMarker ) then setElementData(theMarker, "markerType", "WeaponShop") outputConsole ( "Marker created successfully", thePlayer ) else outputConsole ( "Failed to create marker", thePlayer ) end end end addCommandHandler ( "sell", consoleCreateMarker ) function onPlayerBuyWeaponHandler ( marker ) if not marker then return end destroyElement ( marker ) end addEvent( "onPlayerBuyWeapon", true ) addEventHandler( "onPlayerBuyWeapon", root, onPlayerBuyWeaponHandler ) Client: local inMarker addEventHandler("onClientMarkerLeave", resourceRoot, function( hitElement ) if not hitElement == localPlayer then return end inMarker = nil end) addEventHandler("onClientMarkerLeave", resourceRoot, function( hitElement ) if not hitElement == localPlayer then return end inMarker = source end) addEventHandler("onClientMarkerHit", resourceRoot, function( hitElement ) local markerType = getElementData(source, "markerType") if hitElement == localPlayer and markerType and markerType == "WeaponShop" then panel = guiCreateWindow(471, 143, 493, 575, "Arms Dealer", false) guiWindowSetSizable(panel, false) comprar = guiCreateButton(35, 476, 143, 65, "Buy", false, panel) guiSetFont(comprar, "sa-header") cerrar = guiCreateButton(311, 476, 143, 65, "Close", false, panel) guiSetFont(cerrar, "sa-header") arma1 = guiCreateButton(34, 38, 423, 54, "M4 2000 $", false, panel) guiSetFont(arma1, "sa-header") arma2 = guiCreateButton(34, 112, 423, 54, "AK-47 2000 $", false, panel) guiSetFont(arma2, "sa-header") francotirador = guiCreateButton(34, 358, 423, 54, "Sniper", false, panel) guiSetFont(francotirador, "sa-header") escopeta = guiCreateButton(34, 276, 423, 54, "CombatShotgun 1000 $", false, panel) guiSetFont(escopeta, "sa-header") granada = guiCreateButton(34, 194, 423, 54, "Grenade 500 $", false, panel) guiSetFont(granada, "sa-header") showCursor ( true ) addEventHandler ("onClientGUIClick", comprar, comprarr, false ) addEventHandler ("onClientGUIClick", cerrar, cerrarr, false ) addEventHandler ("onClientGUIClick", arma1, arma11, false ) addEventHandler ("onClientGUIClick", arma2, arma22, false ) addEventHandler ("onClientGUIClick", arma3, arma33, false ) addEventHandler ("onClientGUIClick", arma4, arma44, false ) addEventHandler ("onClientGUIClick", arma5, arma55, false ) end end) function cerrarr ( hitElement ) showCursor ( false ) guiSetVisible (panel, false ) end function comprarr ( hitElement ) showCursor ( false ) guiSetVisible (panel, false ) triggerServerEvent ( "onPlayerBuyWeapon", localPlayer, inMarker) end
  20. No problem. Just try to think what your code will have to do to make it work: 1 - create job marker 2 - show job gui when marker is hitted by a player 3 - go on serverside to set the team when job when accepted then go back to clientside 4 - create a new random house 5 - when hitted, destroy the marker and ask the server to give him cash 6 - go back on step 4 <------ here was the problem
  21. Ofc there is no error because you did that to create a new house: triggerEvent ( "createHouseEvent", localPlayer ) But the event wasn't created and wasn't "linked" with an handler function either. It would work if you added this: addEvent("createHouseEvent", true) addEventHandler ( "createHouseEvent", localPlayer, createHouses ) But I removed a lot of bullshits in your code (gui relative positioning, localPlayer instead of lp, theX and theY on server side, duplicated word in an output etc)
  22. THIS TOPIC HAS BEEN STARTED HERE: https://forum.multitheftauto.com/viewtopic.php?f ... 4&p=666569 Server: addEvent ( "HaveCriminalJob", true) function HaveCriminalJob() triggerClientEvent(source, "HaveCriminalJob", source) --removed theX, theY + source as source setPlayerTeam(source, getTeamFromName("Criminal")) end addEventHandler("HaveCriminalJob", root, HaveCriminalJob) addEvent ( "givePlayerPay", true ) function givePlayerRobPay () local money = math.random ( 150, 2500 ) givePlayerMoney ( source, money ) outputChatBox ( "You successfully robbed the house and made $" ..money, source ) fadeCamera ( source, false, 1, 0, 0, 0 ) setTimer ( fadeCamera, 2500, 1, source, true, 1 ) end addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) Client: local robberHouses = { { 1887, -1113, 25 }, { 2092, -1160, 25 }, { 1896, -1165, 22 }, { 2068, -1720, 13 }, { 1970, -1671, 17 }, { 1895, -1071, 23 }, { 1940, -1066, 23 }, { 1955, -1074, 23 }, { 1960, -1069, 23 }, { 1956, -1115, 26 }, { 1945, -1115, 26 }, { 1924, -1115, 26 }, { 1900, -1114, 26 }, { 2596, -1237, 47 }, { 2595, -1199, 58 }, { 2516, -1028, 69 }, { 2630, -1072, 68 }, { 2794, -1246, 45 }, { 2809, -1176, 25 }, { 2586, -953, 80 } } function getRandomHousePos() return unpack( robberHouses[ math.random( #robberHouses ) ] ) end local jobmarker = createMarker( 2054.4609375, -1759.5224609375, 13.549641609192, "cylinder", 1.5, 255, 153, 0, 150 ) local jobBlip = createBlip( 2054.4609375, -1759.5224609375, 13.549641609192, 52 ) -------- GUI -------- jobwindow = guiCreateWindow(0.3, 0.3, 0.4, 0.4, "Criminal", true) memo = guiCreateMemo(0, 0.05, 0.8, 0.6, "This is house robbing job press Accept and then a red house will appear on your minimap go to the red house blip and rob the house!", true, jobwindow) takebutton = guiCreateButton(0.25, 0.9, 0.2, 0.18, "Accept", true, jobwindow) cancbutton = guiCreateButton(0.55, 0.9, 0.2, 0.18, "Cancel", true, jobwindow) guiMemoSetReadOnly(memo, true) guiWindowSetMovable(jobwindow, false) guiWindowSetSizable(jobwindow, false) guiSetVisible(jobwindow, false) --------------------- addEventHandler("onClientGUIClick", jobwindow, function(b) if b == "left" then if source == takebutton then if getTeamName(getPlayerTeam(localPlayer)) ~= "Criminal" then triggerServerEvent("HaveCriminalJob", localPlayer) outputChatBox ("You are now employed as a Criminal", 255, 255, 0, true) guiSetVisible(jobwindow, false) showCursor(false) end elseif source == cancbutton then guiSetVisible(jobwindow,false) showCursor(false) end end end) addEventHandler("onClientMarkerHit", jobmarker, function(p) if p == localPlayer and not isPedInVehicle(localPlayer) then guiSetVisible(jobwindow,true) showCursor(true) -- sets the cursor visible if getTeamName(getPlayerTeam(localPlayer)) == "Criminal" then outputChatBox("You already have this job.",0,255,0, true) guiSetVisible(jobwindow,false) showCursor(false) end end end) addEvent("HaveCriminalJob", true) function createNewHouse() local x, y, z = getRandomHousePos() robhouseMarker = createMarker( x, y, z, "cylinder", 3, 255, 51, 102, 85) robhouseBlip = createBlipAttachedTo( robhouseMarker, 32) end addEventHandler ( "HaveCriminalJob", localPlayer, createNewHouse ) addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer then triggerServerEvent ( "givePlayerPay", localPlayer ) destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) createNewHouse() --Creating a new house end end) addEventHandler ( "onClientPedDamage", root, function () cancelEvent () end)
  23. He wants us to explain him how to do a custom radar Sorry to say that Jacobob14 but you need to get more skill before doing such complicated stuff. Because someone will try to help you giving you the functions and the main idea of how it has to be done but you won't be able to make it yourself. So someone will finally do the whole code for you (some crazy guys like me ). But I won't be that person this time.
  24. Citizen

    UTF8 problem

    1 - Log into phpMyAdmin. 2 - Select your database. 3 - Click on "Operations" from the top set of tabs. 4 - In the Collation box, choose your new collation from the dropdown menu. utf8_general_ci is the most common utf8 collation/encoding. 5 - Click on Execute/Run button. And then you need to repeat the same operations but on all tables already created (which doesn't have the right collation/encoding). (And maybe for columns of all tables, not sure if they will be updated) The next tables you will create will get the database collation as default so you will be ok.
×
×
  • Create New...