-
Posts
1,803 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Citizen
-
Rien de plus simple, pour travailler avec des dates, il faut manipuler ce qu'on appelle des timestamps. Un timestamp est un nombre qui correspond au nombre de secondes qui s'est écoulé depuis le 1er Janvier 1970. Par exemple le timestamp 1443657600 correspond au 1er Octobre 2015. Pour récupérer ce timestamp, tu vas devoir utiliser getRealTime qui te renvoi par défaut un tableau qui va contenir le timestamp (et d'autres choses) correspondant à la date, l'heure et la seconde actuelles. Tu n'as absolument pas dit quelle base de donnée tu utilisais (SQLite ? MySQL) Pour MySQL, il faut créer une nouvelle colonne de type INTEGER et cocher la case unsigned (non signé). Lorsque le joueur se déconnecte: local currentTime = getRealTime() local timestamp = currentTime.timestamp et tu saves timestamp dans sa colonne. Lorsque le joueur se connecte, tu récupères le timestamp dans une variable genre lastConnectionTimestamp. Vu que c'est pour l'afficher dans un tableau ou panel, tu en as besoin côté client donc on va mettre un petit element data sur le joueur pour stocker notre lastConnectionTimestamp: setElementData(thePlayer, "lastConnectionTimestamp", lastConnectionTimestamp) Un element data est par défaut synchronisé entre le serverside et le clientside. Du côté client il ne te reste plus qu'à convertir le timstamp en date et afficher cette date dans ton tableau: local lastConnectionTimestamp = getElementData(localPlayer, "lastConnectionTimestamp") local lastConnectionDate = getRealTime(lastConnectionTimestamp) lastConnectionDate.monthday pour le numéro du jour. lastConnectionDate.month pour le numéro du mois. lastConnectionDate.year+1900 pour l'année (oui il est basé sur l'an 1900 celui là d'après le wiki oO). lastConnectionDate.hour pour l'heure. lastConnectionDate.minute pour les minutes. lastConnectionDate.second pour les secondes.(à toi de voir si t'as besoin d'un affichage aussi précis : D). N'hésite pas à redemander si tu n'as pas compris un passage.
-
Replace it in the original post then, people who will come here to get your code will just copy and paste from there and probably won't see your fix above.
-
Nan il n'est pas créé mais affiché avec ça. Ce qui crée le bouton, c'est ça: cInterface.tab_3.dxElements.buttons[3] = createElement("dxButton") Mais il a sûrement déjà été créé ailleurs et donc il n'est pas nécessaire de le recréer. Par contre ce code me fait peur, pourrais-tu me montrer comment est créer ce cInterface ? Parce que s'il est créé une seule fois au démarrage de la ressource, on ne devra pas supprimer l'élément. Moi ce qui m’intéresse c'est de voir le code responsable du changement d'onglet et celui responsable d'afficher ou de cacher le userpanel car ça sera sûrement à ces niveaux là que l'on va devoir agir.
-
Mouai, ça a été codé de façon un peu bizarre, je ne m'attendais pas à une telle gestion. Donc de ce que j'ai compris, si tu veux créer un bouton, il te faut d'abord créer un élément de type dxButton et ensuite te mettre dans un "onClientRender" pour appeler un dxLibCreateButton avec l'élément de type dxButton que tu as créé. Exemple: local button1 = createElement("dxButton") function renderTest() dxLibCreateButton(button1,350,760,400,50,"test",3,255,0,120,0,255,0,255,false) end addEventHandler("onClientRender", root, renderTest) Avec ce code là, si tu veux ne plus afficher un élément, il te faut stopper le "onClientRender" mais aussi supprimer l'élément avec la fonction destroyElement. Exemple: removeEventHandler("onClientRender", root, renderTest) destroyElement(button1)
-
Note that obuhhh is right by implicitly saying that the dxDrawRectangle will be a way better than using the dxDrawImage. If your image is only 1px, then there will be only 1 color. Get it as RGB from any image editor tool and use it in the dxDrawRectangle like obuhhh did. By doing that you will prevent players to download an extra image and the render will need less usage of the player's computer resources and for the exact same result.
-
D'après ce que j'ai compris, il y a un onClientRender ou onClientMouseMove qui se charge de "getter" la position de la souris et de parcourir tous ces "dx elements" (dxButton, dxGridlist, dxEdit etc) et si la position de la souris est détecté au-dessus de l'un d'entre heu, il lui "set" un element data à true pour signaler que la souris est actuellement au-dessus. Par exemple pour le bouton, il doit faire quelque chose comme ça: setElementData(dxButton, "dxButtonHover", true, false) Il s'occupe également de le remettre à false s'il la souris en ait sortie. Ailleurs dans le code, on s'occupe de gérer le clic de la souris (c'est le code que tu nous à collé) et va parcourir tous les "dx elements" qui sont cliquables. Pour chaque "dx elements" cliquables, il va "get" l'element data qui précise si la souris est au-dessus, si c'est le cas, il va "trigger" le "onDxLibButtonClick". Ton problème est donc que l'element data "dxButtonHover" reste à true même lorsque le bouton n'est plus visible. Il te faut donc trouver le bon endroit pour remettre cet element data à false: setElementData(dxButton, "dxButtonHover", false, false) Peux-tu nous montrer une partie du onClientRender qui se charge d'afficher tous les dxElements à l'écran ? (ou du moins celui du bouton) Je pense qu'il doit y avoir un "check" (un if blabla then) qui doit vérifier si l'élément est visible (car si on dit que cet element n'est pas visible, il ne faut pas le montrer comme un guiSetVisible(gui, false) ferait.)
-
Nice great job.
-
Just use dxDrawImage and give the width and height of that image. The image will be stretched automatically and will exactly look like a background repeat in css. addEventHandler("onClientRender", root, function () dxDrawImage(200, 200, 400, 400, "image.png") end)
-
Can you add screenshots or a gif or a video to see this code in action ?
-
Of course we need the code to understand what's wrong (you can cut some parts if it's not related to the problem). For the explosions not doing any damage inside the colshape, I think there is, somewhere in the code, a code to cancel any damage inside the colshape like a safe-zone or something like that. Look for the use of onClientPlayerDamage in all the resources currently running with your code and see where that event is canceled and the conditions (if statements) for it. For the second part of the problem, you should kill the timer that is making the turret to shoot (because I guess you started an infinite timer when you entered in the colshape) if there is no player in the colshape anymore.
-
Je serai ok pour te donner des cours gratuitement, j'aimerai donc connaître tes disponibilités. Pour ma part je ne serai pas disponible avant le début du mois prochain.
-
Ok toni012899, read carefully: - Firstly, that's exactly what I said in this post. - Secondly, the problem is solved already. Please read other's posts so you know everything that has been said before posting the same answers/suggestions.
-
Ok toni012899, read carefully: - First, that's exactly what I suggested in this post. - Secondly, we CAN steal your scripts by doing that. It's just harder so "noobs" can't still your scripts even if it's still possible. Please read other's posts so you know everything that has been said before posting the same answers/suggestions.
-
By "table" you mean a Lua table or a gridlist ? (I'm pretty sure you meant gridlist though)
-
That's what Kenix suggested aswell in the same topic I linked: viewtopic.php?p=338904#p338904 But yours a just a bit more complex, I don't know if it's true though.
-
Oh ok, then yes, as you said.
-
- Yes - No you can't send MTA commands like /quit as a player.
-
As far I know there is no way to fully protect your client-side files because the MTA client need to be able to read your files. And if the MTA client is able to read it, then everyone can read or dump it somewhere on his computer. But you can get rid of the low skilled stealers by changing the way the files are loaded. First you can remove all your client-scripts from the meta.xml (but keep an easy to update list of them like clients.xml). Then when a player joins, the server will load all client-script content and send it to the client side as a string using triggers and then use the loadstring lua function to load and run the code. Use the Ransom's code to send and load the scripts: viewtopic.php?p=337791#p337791 For the media files like sounds, textures, images etc, placing an anomaly inside the files is a good idea but must be done on the server files. You will have two folders on the server side one containing all the medias without anomaly, and another folder with the same medias with anomalies (by using a c++, C#, Java, whatever application) and use the medias with anomalies in the meta.xml for the production environment and the medias without anomalies for the dev environment. And of course when deploying onto the real server, you won't upload the folder that contains the medias without anomalies.
-
@venadHD: Please verify if it's possible before dropping methods that will let the OP think it's actually possible. Plus, even if it was possible, the only two functions you dropped here is not helping him at all. For the message part, it's possible by using outputChatBox but you need to replicate the colors for the player's name. You can get the color by using getPlayerNametagColor and it will return the RGB color model of the player's name. To use it in outputChatBox as you want only the player's name to be in that color and not the whole text, you have to set the r, g and a parameters to 255 and the colorCoded parameter to true so you can use multiple colors in the same text message. You will end up with something like this: local playerName = getPlayerName(player) local r, g ,b = getPlayerNametagColor(player) local hexColor = "#"..toHex(r, g, b) -- Convert to hexadecimal string (i.e: "#FFAA55") outputChatBox(hexColor..playerName.."#FFFFFF: "..text, 255, 255, 255, true) Note that toHex is a usefull function so you have to paste the function in your code, you can get it here. Results: If the text is "Hello !" and getPlayerNametagColor(player) returns 255, 255, 0 and the player's name is "John #FF0000Cena" then it will be equivalent to: outputChatBox("#FFFF00John #FF0000Cena: #FFFFFFHello !", 255, 255, 255, true) or: JohnCena: Hello ! For the commands part, the only way to make another player use commands you want is by using the executeCommandHandler function. However, as the wiki says: This means that you can not use the following functions: https://wiki.multitheftauto.com/wiki/Cl ... e_Commands Also, note that there is a getKeyState but no setKeyState for the same security reasons. To summarize the answer: - You can fake a player message by reproducing yourself the entire message (so including the player's name) and the colors so it's impossible to know the player didn't actually wrote this message himself. - But you can't fake player commands if the commands are MTA commands.
-
What do you mean by "I can't add settings" ? Resource settings in the meta.xml ? I can tell you how I did it but it might not be exactly the same for you, that's why I was asking you what exactly wasn't working. 1 - I installed it as administrator and gave the correct path for the MTA San Andreas 1.5 folder and then the correct path for the mta server 1.5. 2 - I launched it as administrator then went into Tools -> Options ... and clicked on the button Integrate with MTA Server or something like that (at the bottom of the window). But the icon saying it's not fully integrated was still there because it didn't update my acl.xml properly. 3 - So I updated the acl.xml manually to add the missing MTASE group (check the acl file in the MTASE folder to see what should be added to your acl.xml 4 - Also the integration process should have copy the MTASE.zip resource into your resources folder. If not, copy it yourself. 5 - After adding the MTASE.zip resource, it should have added this resource in your mtaserver.conf so it's starting automatically with your server. If not, add it yourself. 6 - Created an user account mtase will use and added this user into my acl admin group (check my previous post for more details). 7 - Closed and Started the MTA Script Editor again, went to Tools -> Options ... and filled the Server integration form fields and then clicked on Test connection. 8 - Since then everything was working fine for me.
-
dbConnect is creating the .sql file only if it doesn't exists already. So if you have a .sql database, just give the correct path to it and it will connect to it just fine. So if you put mydb.sql into the "databases" folder just connect to it like this: dbConnect ("sqlite","databases/mydb.sql" )
-
You are creating the new window but you hide it immediately, is that really what you wanted to do at this point of the code ? Are you showing it later ? local gui.newLocation = guiCreateWindow(0, 0, w, h, "Create Teleport © Almighty", false) ... guiSetVisible(gui.newLocation, false) Also, I just read the whole topic, and KariiM did a pretty nice job (with you of course) but you guys are using: guiGridListGetSelectedItem(grid)+1 to know which row has been clicked and get the right row in the table. However this is working only if the gridlist hasn't been reordered. The player can reorder the gridlist by clicking on the column headers. By doing that the 1st row in the gridlist might not match the 1st row in the data table anymore. To fix that you can ask a row (well actually a cell of a row) to store a value for you which will be the corresponding row's number in the data table: function viewGUI (aTable) if ( source == getLocalPlayer() ) then guiSetVisible (window, true) showCursor (true) guiGridListClear(grid) for index ,val in ipairs (aTable) do local row = guiGridListAddRow (grid) guiGridListSetItemText (grid, row, col1, val[1], false, true) guiGridListSetItemText (grid, row, col2, val[2], false, false) guiGridListSetItemText (grid, row, col3, val[3], false, false) guiGridListSetItemData (grid, row, 1, index ) -- storing the row's number (or index) of the [b]data [/b]table end end end and then get it back this way: addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must select the destination !", getLocalPlayer(), 255, 0, 0) return false end guiSetVisible(window, false) showCursor(false) local rowSelected = guiGridListGetSelectedItem(grid) -- getting the gridlist row's number as you did triggerServerEvent("warp", getLocalPlayer(), guiGridListGetItemData (grid, rowSelected, 1)) -- but getting the [b]data [/b]table index from the row instead of doing a +1 end end) So now the gridlist can be reordered as much as it wants to, our item data we set won't be modified. @KariiiM: Nice to see you now helping others (I remember I was helping you not so much time ago). Keep doing that, you are helping the community and it's great. However if I can say just one thing, try to indent your code properly: 1 tab or 4 spaces is the recommended size for 1 level of indentation. The code is more readable and you can instantly see if you missed for example an end to close an opened if or a for loop or whatever. Thanks and keep up the good work.
-
Trust me, the config.ini doesn't contain any interesting settings for it to work (except for the [sERVER_INTEGRATION] section only containing my admin account credentials that I can't post obviously). What is/are the problem(s) you are facing ? We can fix it together. The way MTASE has been made allow it to work on recent versions of MTA without the need of updating the program itself. But yeah as you said it failed to set some settings like updating the acl.xml, but we can do it manually. If you have an access denied error for the MTASE resource in the server console that's the acl.xml problem. In this case attach/paste your acl.xml so I can see what is missing. For the server integration, you need to create an account for MTASE by writing addaccount accountName password in the server console. Once created, shutdown the server and edit your acl.xml to add this user in the Admin group by adding it like so: <group name="Admin"> ... <object name="user.accountName"></object> </group> Then restart the server and try to submit the credentials in Tools > Options > Integration with MTA Server form. But as I said the function database is outdated and we need a volunteer to make a script/program to update the database as it would take ages to do it manually.
-
Then why not asking bluntz to help you directly ? I won't help you aswell.
-
Also stealing codes or entire resources and then asking for help to fix/modify it is just a joke. I can't believe some of the community members are doing that, it's a shame. The solution to your question is obvious for all decent scripters (no need to be a Lua/MTA pro to know what to modify), and should be even more obvious for the one who really made this code. As your question shows it: You are not the one who made this script, neither a good scripter. It's time to do things by yourself and learn the basis of Lua/MTA. And you won't learn by posting 1 topic a day to ask for someone to do it for you.