xUltimate
Members-
Posts
92 -
Joined
-
Last visited
Everything posted by xUltimate
-
Using carshop = createMarker(1751.32, -2055.36, 12.71, "cylinder", 1, 0, 255, 0, 180) carshopcol = createColSphere ( 1751.32, -2055.36, 13.71, 1 ) local cars = { 400, 401, 402, 404, 405, 409, 410, 411 } local prices = { 5995, 4995, 6995, 3495, 7999, 34995, 7995, 125000 } addEventHandler("onClientResourceStart", resourceRoot, function() Window = {} Button = {} Grid = {} Window[1] = guiCreateWindow(558, 219, 302, 324, "Los Santos Car Shop", false) Grid[1] = guiCreateGridList(10, 26, 283, 244, false, Window[1]) guiGridListSetSelectionMode(Grid[1], 2) local column1 = guiGridListAddColumn(Grid[1], "Vehicle", 0.50) local column2 = guiGridListAddColumn(Grid[1], "Price", 0.40) if (column1 and column2) then for a = 1,#cars do local name = getVehicleNameFromModel(cars[a]) local prices = tostring(prices[a]) local row = guiGridListAddRow(Grid[1]) if name ~= "" then guiGridListSetItemText(Grid[1], row, column1, name, false, false) guiGridListSetItemText(Grid[1], row, column2, prices, false, false) end end end Button[1] = guiCreateButton(17, 295, 73, 20, "Purchase", false, Window[1]) Button[2] = guiCreateButton(219, 294, 73, 20, "Cancel", false, Window[1]) guiSetVisible( Window[1], false ) addEventHandler("onClientGUIClick", Button[1], purchaseCar, false ) addEventHandler("onClientGUIClick", Button[2], hideGUI, false ) ------------------------------------------------------------------------------------ end ) function showGUI() guiSetVisible( Window[1], true ) end addEventHandler("onClientColShapeHit",getRootElement(),showGUI) function hideGUI() guiSetVisible( Window[1], false ) end function purchaseCar() guiSetVisible( Window[1], false ) local sig = guiGridListGetSelectedItem(Grid[1]) local price = guiGridListGetItemText(Grid[1], sig, column2) if exports.players:takeMoney(client, price) then -- try to create a permanent one local car = guiGridListGetItemText(Grid[1], sig1, column1) local vehicle, vehicleID = exports.vehicles:create(client, car) if vehicle then local vehname = getVehicleName(vehicle) outputChatBox( "Congratulations! You've bought a " .. vehname .. "!", client, 255, 127, 0 ) outputChatBox( "Remember to use /park to set a permanent spawn position for this vehicle.", client, 255, 255, 0 ) spawnVehicle(vehicle, 1758.65, -2056.82, 13.58, 0, 0, 0) -- give him the keys exports.items:give( client, 1, vehicleID, vehname ) else -- failed somewhere exports.players:giveMoney( client, price ) end else outputChatBox( "A error occured, this was expected.", source, 255, 0, 0 ) end end It is unable to get the price from the text and prints out in the debug "ERROR: call: failed to call 'players:takeMoney' [string "?"]"
-
Ok, haha i'll try that sorry if anything i ask is newby, im really new to working with GUI. EDIT: Great it works when someone walks in the marker, but how would I go about loading a xml or a file that has a list like "Sultan", "95000"; "Rancher", "50000"; and it loads the data into the grid and displays it?
-
vehicles[ source ] == Call the SQL to lookup the vehicleid the person is in vehicles[ vehicle ] == Call the SQL to lookup all cars in the database so I use vehicles[ source ]
-
carshop = createMarker(1751.32, -2055.36, 12.71, "cylinder", 1, 0, 255, 0, 180) carshopcol = createColSphere ( 1751.32, -2055.36, 13.71, 1 ) function showGUI() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(558,219,302,324,"Los Santos Car Shop",false) GUIEditor_Grid[1] = guiCreateGridList(10,26,283,244,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) guiGridListAddRow(GUIEditor_Grid[1]) guiGridListAddColumn(GUIEditor_Grid[1],"Vehicle",0.2) guiGridListAddColumn(GUIEditor_Grid[1],"Price",0.2) GUIEditor_Button[1] = guiCreateButton(17,295,73,20,"Purchase",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(219,294,73,20,"Cancel",false,GUIEditor_Window[1]) end addEventHandler("onColShapeHit", carshopcol, showGUI) Its supposed to show the GUI window when someone enters the colsphere but it doesnt.
-
What do you mean? Whats wrong with the SQL?
-
Ewww... i know thats simplified but i like looking at codes organized lol.
-
I was attempting to make a togwindow command but apparently it does not want to comply. The cmd: addCommandHandler( "togwindows", function ( player, vehicle ) if exports.players:isLoggedIn( player ) then if isPedInVehicle ( player ) then local data = vehicles[ source ] if data then if data.vehicleID > 0 then if data.windows == 0 then local success, error = exports.sql:query_free( "UPDATE vehicles SET windows = 1 WHERE vehicleID = " .. data.vehicleID ) if success then exports.chat:me( source, "rolls the windows up.") end if error then outputChatBox( "My-SQL Error.", source, 255, 0, 0 ) end elseif data.windows == 1 then local success, error = exports.sql:query_free( "UPDATE vehicles SET windows = 0 WHERE vehicleID = " .. data.vehicleID ) if success then exports.chat:me( source, "rolls the windows down.") end if error then outputChatBox( "My-SQL Error.", source, 255, 0, 0 ) end end else outputChatBox( "You cant do this with a temporary vehicle. (SQL Error)", source, 255, 0, 0 ) end end else outputChatBox( "You are not in a vehicle.", player, 255, 0, 0 ) end end end ) When I do /togwindows it shows no errors, warnings or anything it just does nothing.
-
lol? No they just make it so it says "rolls the windows down" or "rolls the windows up"
-
^^ lol.... You can script it to where valhalla has it.
-
Well, there's about 7 different resources that call it so... and I kinda went with the old system just modified a bit.
-
It's in another part of the script.
-
In the console it says "Unable to find drop-off point, leaving player-name with nothing to do"
-
I'm trying to make it to where I can create a delivery point, It creates the point and adds it in the SQL but the job is unable to find the location. Job part function addDropOff( dimension ) if getResourceState( getResourceFromName( "deliverypoints" ) ) == "running" then markedToAdd[ dimension ] = nil for k, v in ipairs( dropOffs ) do if v.dimension == dimension then return end end local interior = exports.deliverypoints:getDeliverypoint( dimension ) if interior then if getElementDimension( interior.outside ) == 0 then local x, y, z if interior.dropoff then x, y, z = unpack( interior.dropoff ) else x, y, z = getElementPosition( interior.outside ) local cx, cy, cz = exports['vehicle-nodes']:findClosest( x, y, z ) if cx then x = ( 1.3 * x + cx ) / 2.3 y = ( 1.3 * y + cy ) / 2.3 z = ( 1.3 * z + cz ) / 2.3 z = ( 1.3 * z + cz ) / 2.3 end end table.insert( dropOffs, { x = x, y = y, z = z, dimension = dimension, name = interior.name } ) end end else markedToAdd[ dimension ] = true end end Delivery lua local addCommandHandler_ = addCommandHandler addCommandHandler = function( commandName, fn, restricted, caseSensitive ) -- add the default command handlers if type( commandName ) ~= "table" then commandName = { commandName } end for key, value in ipairs( commandName ) do if key == 1 then addCommandHandler_( value, fn, restricted, caseSensitive ) else addCommandHandler_( value, function( player, ... ) -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay) if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then fn( player, ... ) end end ) end end -- check for alternative handlers, such as createinterior = createint for k, v in ipairs( commandName ) do if v:find( "deliverypoint" ) then for key, value in pairs( { "dp" } ) do local newCommand = v:gsub( "deliverypoint", value ) if newCommand ~= v then -- add a second (replaced) command handler addCommandHandler_( newCommand, function( player, ... ) -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay) if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then fn( player, ... ) end end ) end end end end end -- local dpoints = { } addEventHandler( "onResourceStart", resourceRoot, function( ) if not exports.sql:create_table( 'deliverypoints', { { name = 'dpointID', type = 'int(10) unsigned', auto_increment = true, primary_key = true }, { name = 'x', type = 'float' }, { name = 'y', type = 'float' }, { name = 'z', type = 'float' }, { name = 'name', type = 'varchar(255)' }, } ) then cancelEvent( ) return end -- end ) -- addCommandHandler( "getdeliverypoint", function( player, ... ) -- check if he has permissions to see at least one prop local int = dpoints[ getElementDimension( player ) ] if int then if hasObjectPermissionTo( player, "command.createinterior", false ) or hasObjectPermissionTo( player, "command.deleteinterior", false ) or hasObjectPermissionTo( player, "command.setinterior", false ) or hasObjectPermissionTo( player, "command.setinteriorprice", false ) then local interior = getElementInterior( int.inside ) local x, y, z = getElementPosition( int.inside ) -- check if he has permissions to view each of the props outputChatBox( "-- Delivery Point " .. getElementDimension( player ) .. " --", player, 255, 255, 255 ) if hasObjectPermissionTo( player, "command.createinterior", false ) or hasObjectPermissionTo( player, "command.deleteinterior", false ) or hasObjectPermissionTo( player, "command.setinterior", false ) then outputChatBox( "id: " .. name, player, 255, 255, 255 ) end if hasObjectPermissionTo( player, "command.createinterior", false ) or hasObjectPermissionTo( player, "command.setinteriorname", false ) then outputChatBox( "name: " .. int.name, player, 255, 255, 255 ) end else outputChatBox( "Your Delivery Point: " .. getElementDimension( player ), player ,255, 255, 255 ) end else outputChatBox( "You are not in an interior.", player, 255, 0, 0 ) end end ) addCommandHandler( "createdeliverypoint", function( player, commandName, ...) if ( ... ) then local name = table.concat( { ... }, " " ) local x, y, z = getElementPosition( player ) x = math.ceil( x * 100 ) / 100 y = math.ceil( y * 100 ) / 100 z = math.ceil( z * 100 ) / 100 local insertid, e = exports.sql:query_insertid( "INSERT INTO deliverypoints (`x`, `y`, `z`, `name`) VALUES (" .. table.concat( { x, y, z, '"%s"' }, ", " ) .. ")", name ) if insertid then outputChatBox( "Delivery Point created. (ID " .. insertid .. ")", player, 0, 255, 0 ) -- delete the marked position else outputChatBox( "MySQL-Query failed.", player, 255, 0, 0 ) end else outputChatBox("Error Occured", player, 255, 0, 0) end end, true ) addCommandHandler( { "deletedeliverypoint", "deldeliverypoint" }, function( player, commandName, dpointID ) dpointID = tonumber( dpointID ) if teleportID then local dpoint = dpoints[ dpointID ] if teleport then if exports.sql:query_free( "DELETE FROM deliverypoints WHERE ID = " .. dpointID ) then outputChatBox( "You deleted Delivery Point " .. dpointID .. ".", player, 0, 255, 153 ) else outputChatBox( "MySQL-Query failed.", player, 255, 0, 0 ) end else outputChatBox( "Delivery Point not found.", player, 255, 0, 0 ) end else outputChatBox( "Syntax: /" .. commandName .. " [id]", player, 255, 255, 255 ) end end, true )
-
More information please, you can't expect people to buy if you don't provide more information. Eg. What other services do you provide? What are the prices on these services? What control panels do you offer?
-
Not once was i gonna ask how to fix it.
-
When did I say "how to fix?" lol
-
Ok, so in my server I have this thing called "salt" and a player cant login without it in there name on the sql, I made a UCP where they can register but I can't figure out the salt. Here's the "salt" -- generate a salt (SHA1) local salt = '' local chars = { 'a', 'b', 'c', 'd', 'e', 'f', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } for i = 1, 40 do salt = salt .. chars[ math.random( 1, #chars ) ] end -- create the user if exports.sql:query_free( "INSERT INTO wcf1_user (username,salt,password) VALUES ('%s', '%s', SHA1(CONCAT('%s', SHA1(CONCAT('%s', '" .. sha1( password ) .. "')))))", username, salt, salt, salt ) then triggerClientEvent( source, getResourceName( resource ) .. ":registrationResult", source, 0 ) -- will automatically login when this is sent else
-
It's only temporary, I'm only using it to test my server that I have not connected to MTA for users to join, I use it to test my new UCP and such, we're having trouble getting the server to run on the hosting server but we'll fix it sometime soon.
-
Recently I tried to access my external server to use my MTA server's MySQL on it and it fails to connect, I am unsure why though. Here is my settings file (Note: I have taken out parts for security purposes only) <setting name="@sql.user" value="----" /> <setting name="@sql.password" value="----" /> <setting name="@sql.database" value="----_mtasa" /> <setting name="@sql.hostname" value="174.121.95.47" /> <setting name="@sql.port" value="3306" /> I have User, Password, and Database entered correctly, its either the hostname or the port that is throwing it off.
-
Ok for the final time, I have debugged all my scripts, and it does nothing.
-
I can make 3D models
-
Just edited it and I think this should work but somewhere else I am messing up, it still skips to "Critical Error" addCommandHandler( "impound", function( player, commandName ) local vehicle = getPedOccupiedVehicle( player ) if vehicle then local data = vehicles[ vehicle ] if data then if data.impounded == 0 then if data.vehicleID < 0 then outputChatBox( "Your temporary vehicle " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") can't be impounded.", player, 255, 0, 0 ) elseif ( data.characterID > 0 and exports.factions:isPlayerInFaction( player, 4 ) or exports.factions:isPlayerInFaction( player, 1 ) or hasObjectPermissionTo( player, "command.createvehicle", false )) then local x, y, z = getElementPosition( vehicle ) local rx, ry, rz = getVehicleRotation( vehicle ) local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( vehicle ) .. ", respawnDimension = " .. getElementDimension( vehicle ) .. ", impounded = 1 WHERE vehicleID = " .. data.vehicleID ) if success then setVehicleFrozen(vehicle, true) setVehicleRespawnPosition( vehicle, x, y, z, rx, ry, rz ) data.respawnInterior = getElementInterior( vehicle ) data.respawnDimension = getElementDimension( vehicle ) saveVehicle( vehicle ) outputChatBox( "Vehicle " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") has been impounded.", player, 0, 255, 0 ) else outputChatBox( "Impounding Vehicle failed.", player, 255, 0, 0 ) end else outputChatBox( "You cannot impound vehicles.", player, 255, 0, 0 ) end elseif data.impounded == 1 then if data.vehicleID < 0 then outputChatBox( "Your temporary vehicle " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") can't be impounded.", player, 255, 0, 0 ) elseif ( data.characterID > 0 and exports.factions:isPlayerInFaction( player, 4 ) or exports.factions:isPlayerInFaction( player, 1 ) or hasObjectPermissionTo( player, "command.createvehicle", false ) ) then local success, error = exports.sql:query_free( "UPDATE vehicles SET impounded = 0 WHERE vehicleID = " .. data.vehicleID ) if success then setVehicleFrozen(vehicle, false) outputChatBox( "Vehicle " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") has been unimpounded.", player, 0, 255, 0 ) else outputChatBox( "Unimpounding vehicle failed.", player, 0, 255, 0 ) end else outputChatBox( "You cannot unimpound vehicles.", player, 255, 0, 0 ) end else outputChatBox( "Critical Error.", player, 255, 0, 0 ) end end else outputChatBox( "You are not driving a vehicle.", player, 255, 0, 0 ) end end )
-
Ya I tried something like that earlier but it failed.
