Jump to content

I am creating a pay n spray script and i need help in it ...


Recommended Posts

I have created a GUI code

code is ->

GUIEditor = {

button = {},

window = {},

label = {},

memo = {}

}

GUIEditor.window[1] = guiCreateWindow(122, 97, 583, 368, "Pay N Spray", false)

guiWindowSetSizable(GUIEditor.window[1], false)

GUIEditor.memo[1] = guiCreateMemo(38, 28, 516, 222, "Cost :- Minimum :-10$\n Maximum :- 20000$\n\nINFORMATION :- \n1. If your car is broken you can repair it here . You cant change the color of the car for that go to upgrade shop.\n2. You will need to pay money to repair your car.\n3. If damage in your car is more the cost will be more .\n4. Cost of repair depends upon the type of Vehicle you have.", false, GUIEditor.window[1])

GUIEditor.button[1] = guiCreateButton(359, 270, 195, 46, "Repair", false, GUIEditor.window[1])

GUIEditor.button[2] = guiCreateButton(48, 273, 143, 43, "Cancel", false, GUIEditor.window[1])

GUIEditor.label[1] = guiCreateLabel(445, 344, 128, 24, "Designed by sankalp21", false, GUIEditor.window[1])

Now what help is needed

1.) i want this GUI to come when i hit the marker on coordinates XYZ

2.) when GUIEditor.button[1] is pressed it fixes the car and reduces the money of player as per percentage of damage of car.

3.) (IF possible) if the vehicle is low rider car than the cost of repair will be less ... if it is helicopter then the cost will be more if it is sports car than repair cost will be high ....... like this

Link to comment

here are the functions and events you'll need

if you don't know how to use it, click it and check what it does in wiki, and try something then show us your code.

  
--functions-- 
createMarker -- create a marker 
fixVehicle -- fix vehicle 
guiSetVisible -- for close and open 
getPlayerMoney -- get the player's money amount 
takePlayerMoney -- take the player's money 
getPedOccupiedVehicle -- check the car the player is on 
getElementModel -- to check the car ID for the low costs and high costs as you said 
  
--events-- 
onClientMarkerHit -- use guiSetVisible here 
onClientGUIClick -- clicking the buttons  

Link to comment
here are the functions and events you'll need

if you don't know how to use it, click it and check what it does in wiki, and try something then show us your code.

  
--functions-- 
createMarker -- create a marker 
fixVehicle -- fix vehicle 
guiSetVisible -- for close and open 
getPlayerMoney -- get the player's money amount 
takePlayerMoney -- take the player's money 
getPedOccupiedVehicle -- check the car the player is on 
getElementModel -- to check the car ID for the low costs and high costs as you said 
  
--events-- 
onClientMarkerHit -- use guiSetVisible here 
onClientGUIClick -- clicking the buttons  

Ok thanks for letting me try this ....

Link to comment
here are the functions and events you'll need

if you don't know how to use it, click it and check what it does in wiki, and try something then show us your code.

  
--functions-- 
createMarker -- create a marker 
fixVehicle -- fix vehicle 
guiSetVisible -- for close and open 
getPlayerMoney -- get the player's money amount 
takePlayerMoney -- take the player's money 
getPedOccupiedVehicle -- check the car the player is on 
getElementModel -- to check the car ID for the low costs and high costs as you said 
  
--events-- 
onClientMarkerHit -- use guiSetVisible here 
onClientGUIClick -- clicking the buttons  

Before starting i need one help ... what is Client and What is server ? i saw in many scripts there are clients and server

Link to comment

try this not tested. sorry if im wrong i just woke up. ( it might have missing ends or more, just test , i'm glad if there aren't.)

Client:

local marker = createMarker(x,y,z, "type", size, r, g, b, a) 
  
GUIEditor = { 
button = {}, 
window = {}, 
label = {}, 
memo = {} 
} 
GUIEditor.window[1] = guiCreateWindow(122, 97, 583, 368, "Pay N Spray", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetVisible(GUIEditor.window[1], false) 
GUIEditor.memo[1] = guiCreateMemo(38, 28, 516, 222, "Cost :- Minimum :-10$\n Maximum :- 20000$\n\nINFORMATION :- \n1. If your car is broken you can repair it here . You cant change the color of the car for that go to upgrade shop.\n2. You will need to pay money to repair your car.\n3. If damage in your car is more the cost will be more .\n4. Cost of repair depends upon the type of Vehicle you have.", false, GUIEditor.window[1]) 
GUIEditor.button[1] = guiCreateButton(359, 270, 195, 46, "Repair", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(48, 273, 143, 43, "Cancel", false, GUIEditor.window[1]) 
GUIEditor.label[1] = guiCreateLabel(445, 344, 128, 24, "Designed by sankalp21", false, GUIEditor.window[1]) 
  
function markerhit(player) 
if not isPedInVehicle(localPlayer) then return end 
if (player == localPlayer) then 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end 
end 
addEventHandler("onClientMarkerHit", marker, markerhit) 
  
addEventHandler("onClientGUIClick",resourceRoot,function() 
    if (source == GUIEditor.button[1]) then 
    guiSetVisible(GUIEditor.window[1],false) 
    showCursor(false) 
    triggerServerEvent("repair", localPlayer, localPlayer) 
    elseif ( source == GUIEditor.button[2]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
       end 
   end ) 
  

SERVER:

  
function repair(thePlayer) 
local vehicle = getPedOccupiedVehicle(thePlayer) 
local money = getPlayerMoney(thePlayer) 
local model = getElementModel(vehicle) 
if not vehicle then return end 
if (money >= 100) then 
takePlayerMoney(thePlayer, 100) 
fixVehicle(vehicle) 
else 
outputChatBox("not enough money to fix your vehicle", thePlayer) 
end 
if model == vehicleids then 
if (money >= 1000) then 
takePlayerMoney(thePlayer, 1000) 
fixVehicle(vehicle) 
else 
outputChatBox("not enough money to fix your vehicle", thePlayer) 
end 
end 
addEvent("repair", true) 
addEventHandler("repair", getRootElement(), repair) 
  

Link to comment
try this not tested. sorry if im wrong i just woke up. ( it might have missing ends or more, just test , i'm glad if there aren't.)

Client:

local marker = createMarker(x,y,z, "type", size, r, g, b, a) 
  
GUIEditor = { 
button = {}, 
window = {}, 
label = {}, 
memo = {} 
} 
GUIEditor.window[1] = guiCreateWindow(122, 97, 583, 368, "Pay N Spray", false) 
guiWindowSetSizable(GUIEditor.window[1], false) 
guiSetVisible(GUIEditor.window[1], false) 
GUIEditor.memo[1] = guiCreateMemo(38, 28, 516, 222, "Cost :- Minimum :-10$\n Maximum :- 20000$\n\nINFORMATION :- \n1. If your car is broken you can repair it here . You cant change the color of the car for that go to upgrade shop.\n2. You will need to pay money to repair your car.\n3. If damage in your car is more the cost will be more .\n4. Cost of repair depends upon the type of Vehicle you have.", false, GUIEditor.window[1]) 
GUIEditor.button[1] = guiCreateButton(359, 270, 195, 46, "Repair", false, GUIEditor.window[1]) 
GUIEditor.button[2] = guiCreateButton(48, 273, 143, 43, "Cancel", false, GUIEditor.window[1]) 
GUIEditor.label[1] = guiCreateLabel(445, 344, 128, 24, "Designed by sankalp21", false, GUIEditor.window[1]) 
  
function markerhit(player) 
if not isPedInVehicle(localPlayer) then return end 
if (player == localPlayer) then 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end 
end 
addEventHandler("onClientMarkerHit", marker, markerhit) 
  
addEventHandler("onClientGUIClick",resourceRoot,function() 
    if (source == GUIEditor.button[1]) then 
    guiSetVisible(GUIEditor.window[1],false) 
    showCursor(false) 
    triggerServerEvent("repair", localPlayer, localPlayer) 
    elseif ( source == GUIEditor.button[2]) then 
           guiSetVisible(GUIEditor.window[1],false) 
           showCursor(false) 
       end 
   end ) 
  

SERVER:

  
function repair(thePlayer) 
local vehicle = getPedOccupiedVehicle(thePlayer) 
local money = getPlayerMoney(thePlayer) 
local model = getElementModel(vehicle) 
if not vehicle then return end 
if (money >= 100) then 
takePlayerMoney(thePlayer, 100) 
fixVehicle(vehicle) 
else 
outputChatBox("not enough money to fix your vehicle", thePlayer) 
end 
if model == vehicleids then 
if (money >= 1000) then 
takePlayerMoney(thePlayer, 1000) 
fixVehicle(vehicle) 
else 
outputChatBox("not enough money to fix your vehicle", thePlayer) 
end 
end 
addEvent("repair", true) 
addEventHandler("repair", getRootElement(), repair) 
  

NOt working ... when i get in vehicle and go to the marker the GUI comes when i click on repair nothing happens only thing happens in GUI closes

Link to comment

try this.

function repair(thePlayer) 
local vehicle = getPedOccupiedVehicle(thePlayer) 
local money = getPlayerMoney(thePlayer) 
local model = getElementModel(vehicle) 
if not vehicle then return end 
if (money >= 100) then 
takePlayerMoney(thePlayer, 100) 
fixVehicle(vehicle) 
else 
outputChatBox("not enough money to fix your vehicle", thePlayer) 
end 
end 
addEvent("repair", true) 
addEventHandler("repair", getRootElement(), repair) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...