 
        andreiwow2
Members- 
                Posts27
- 
                Joined
- 
                Last visited
Everything posted by andreiwow2
- 
	Hey guys, I'd like to make an accessory system where people could attach hats and glasses and other things to them but I heard that this may cause stuttering, the server that this is aimed for has around 120+ players, do you have any ideas how to do this without performance issues?
- 
	And can you show me the working example of what I've been trying to do please? What should I modify at my code, sorry but I understand better from examples.
- 
	Hey guys, I've done this: <meta> <info author="Andrei" description="Pay phone script" version="0.7" name="PayPhones"/> <script src="main.lua" type="server" /> <script src="client.lua" type="client" /> <min_mta_version server="1.1.1-9.03328" /> </meta> Server file: addCommandHandler("payphone", function(sourcePlayer) for i=1, payLength do if isElementInRange(sourcePlayer, payphones["PosX"..i], payphones["PosY"..i], payphones["PosZ"..i], 1) then triggerClientEvent(sourcePlayer, "onPayPhone", sourcePlayer) end end end ) Client file: addEvent("onPayPhone", true) function displayPayPhone(sourcePlayer) phoneWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Pay Phone", true ) end addEventHandler("onPayPhone", sourcePlayer, onPayPhone) Nothing happens when I type /payphone
- 
	Oh wait, so you say to have the client in a different lua file? Woah... and how do I use the variables from a file to another one? Like if I display the window in the client.lua, how do I pass information to the server file to use it later, for example, if the player calls someone
- 
	Can you tell me where to find the debug, because with client nothing works and nothing is displayed in console This also works, but I still get the "attempt to call global 'guiCreateWindow'" error
- 
	[QUESTION] Please explain to me how tables workandreiwow2 replied to andreiwow2's topic in Scripting It does help, thank you!
- 
	so now you tell me to use shared? with shared, my script works, but not the gui I get the "attempt to call global 'guiCreateWindow' error with client, nothing works.
- 
	Can't I just have server and client in same resource? if I use type="client" nothing works...
- 
	Nothing works now...
- 
	Why would it work in the cmd and not in the loop if it was otherwise? <script src="main.lua" type="shared" />
- 
	[QUESTION] Please explain to me how tables workandreiwow2 replied to andreiwow2's topic in Scripting I've done this function assignPayPhones (res) local checkNumberQuery = dbQuery(handler, "SELECT * FROM PayPhoneOW") local result, num_affected_rows, last_insert_id = dbPoll ( checkNumberQuery, -1 ) payphones = {} payLength = 0 for _, row in ipairs (result) do for column, value in pairs ( row ) do end payphones["ID".._] = row["ID"]; payphones["PosX".._] = row["PosX"]; payphones["PosY".._] = row["PosY"]; payphones["PosZ".._] = row["PosZ"]; payphones["Number".._] = row["Number"]; payLength = payLength + 1 end end addEventHandler("onResourceStart", getRootElement(), assignPayPhones) and it works I just want to have the values of each payphone saved so I can use them later without doing a query.
- 
	Thanks
- 
	This code is working: function testCmd(sourcePlayer) local phoneWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Pay Phone", true ) local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, phoneWindow ) local mainTab = guiCreateTab( "Phone", tabPanel ) end addCommandHandler("testcmd", testCmd) But this code is not working: function displayPayPhone(sourcePlayer) for i=1, payLength do if isElementInRange(sourcePlayer, payphones["PosX"..i], payphones["PosY"..i], payphones["PosZ"..i], 1) then local phoneWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Pay Phone", true ) local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, phoneWindow ) local mainTab = guiCreateTab( "Phone", tabPanel ) end end end addCommandHandler("payphone", displayPayPhone) Error:
- 
	[QUESTION] Please explain to me how tables workandreiwow2 replied to andreiwow2's topic in Scripting I want to save the data of every payphone so I can use it later, for example to get the pos of a payphone to see if the player is near any payphone..
- 
	for i=1, 3 do if isElementInRange(sourcePlayer, payphones["PosX"..i], payphones["PosY"..i], payphones["PosZ"..i], 5) then outputChatBox("There is a payphone near you") else outputChatBox("There is no pay phone near you") end end Error:
- 
	So... I am used to samp enums that looks like this: enum ePlayerInfo { name, type, Float:lastX, Float:lastY, Float:lastX, }; // to store the player info new gPlayerInfo[MAX_PLAYERS][ePlayerInfo]; public function onPlayerConnect(player) { gPlayerInfo[player][name] = getPlayerName(player); gPlayerInfo[player][type] = 0; } Simple But how do I do that with tables? For example table = {} table["name"] = MyName -- this will assign MyName to key name, right? But how do I set an ID to that key so I can identify it later... for example if I have this loop for _, row in ipairs (result) do for column, value in pairs ( row ) do end payphones[_]["PosX"] = row["PosX"]; payphones[_]["PosY"] = row["PosY"]; payphones[_]["PosZ"] = row["PosZ"]; outputChatBox(payphones[_]["PosX"]) end _ - is the loop increment first loop should assign PosX, PosY and PosZ to ID 1 and so on... 2, 3... payphones[1]["PosX"] should return the posx of the first item... payphones[2]["PosX"] should return the posx of the second item... how do I do this... because it doesn't work this way.. I get this error: "attempt to index field '?' (a nil value)"
- 
	I fixed it with the second query, that was the issue
- 
	Hey guys, this is my query: local createPPQuery = dbQuery(handler, "INSERT INTO PayPhoneOW VALUES (`PosX`,`PosY`,`PosZ`,`Number`)", x, y, z, phonenumber) dbFree(createPPQuery) The error is "Column count doesn't match value count at row 1" if I add ID infront of PosX and also a value for it infront of 'x' then it will work, but ID is auto increment and I don't want to set any value for it when I insert, what is the workaround? Also 'x', 'y' and 'z' along with the 'phonenumber' doesn't insert anything in the db but if I print them they are okay. Should the query be like this maybe? local createPPQuery = dbQuery(handler, "INSERT INTO `PayPhoneOW` (`PosX`,`PosY`,`PosZ`,`Number`) VALUES (?,?,?,?)", x, y, z, phonenumber) if so, then they should update the wiki and add such an example too because I had to guess it myself...
- 
	Hey guys, I get the following error: "payphone\main.lua:23: dbPoll failed; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version and for the right syntax to use near 'WHERE Number = 906366 at line 1" This is the code: local checkNr = dbQuery(handler, "SELECT * FROM PayPhoneOW LIMIT 1 WHERE Number = ".. phonenumber) local result, num_affected_rows, last_insert_id = dbPoll ( checkNr, -1 ) outputChatBox(tostring(num_affected_rows)) Fixed... LIMIT 1 was infront of WHERE... sorry....
- 
	And how do I get the result from dbPoll? Like if I want to print the USERNAME
- 
	Hey guys, I've checked the wiki but I don't really understand it, my question is, how do I print or store the result of a query? For example. dbQuery( myCallback, handler, "SELECT * FROM USERS LIMIT 1" ) How do I store the values in a table for exame? userInfo = {}; Also, when should I use ; and when not? Because I see so many examples, some use ; and others doesn't... I've tried this: function createPayPhone() handler = dbConnect( "mysql", "dbname=somedb;host=x.x.x", "someuser", "somepass", "share=1" ) if ( not handler ) then outputDebugString("Unable to connect to the MySQL server") else outputChatBox("Connected") local check = dbQuery(, handler, "SELECT * FROM USERS LIMIT 1" ) local result = dbPoll (check, 2000) for _, row in ipairs ( result ) do for column, value in pairs ( row ) do end outputChatBox(row["USERNAME"]) end end end addCommandHandler("testcon", createPayPhone) but nothing happens when I type the command. #FIXED, the issue was a misplaced " , "!
- 
	When will be next big version? Also why are few people on MTA than on SAMP it has more features.. 70% of mta servers are empty..
- 
	How to get the new objects in MTA editor? like colored lights, billard i think it is named, and the 0.3.7 objects
- 
	I suggest to make the maximum size to 150x150, they are not big and they look nice at that size...
- 
	This happens to me too... My antivirus is AVG.
