Jump to content

WarpPedIntoVehicle - Car dealer Problem


Rotti

Recommended Posts

Hello!

I want t script a car dealer. When you buy a car you should be warped into the Vehicle. But that doesn't works...

Serverside script

function Faggio_buy (ThePlayer) 
    local Faggio = createVehicle(462, -2600, 2268, 
     setTimer(warpPedIntoVehicle, 50, 1, ThePlayer, Faggio) 
end 
  
function Perennial_buy (thePlayer) 
    local Perennial = createVehicle(404, -2600, 2268, 
        setTimer(warpPedIntoVehicle, 50, 1, ThePlayer, Perennial) 
end 
  
function Walton_buy (thePlayer) 
    local Walton = createVehicle(478, -2600, 2268, 
        setTimer(warpPedIntoVehicle, 50, 1, ThePlayer, Walton) 
end 
  
function Tampa_buy (thePlayer) 
    local Tampa = createVehicle(549, -2600, 2268, 
        setTimer(warpPedIntoVehicle, 50, 1, ThePlayer, Faggio) 
end 
  
addEvent("Faggio", true) 
addEvent("Perennial", true) 
addEvent("Walton", true) 
addEvent("Tampa", true) 
addEventHandler("Faggio",getRootElement (), Faggio_buy) 
addEventHandler("Perennial", getRootElement (), Perennial_buy) 
addEventHandler("Walton", getRootElement (), Walton_buy) 
addEventHandler("Tampa", getRootElement (), Tampa_buy) 

Clientside script

    Window = guiCreateWindow(583, 409, 197, 327, "Fake Cars", false) 
    guiWindowSetSizable(Window, false) 
    guiSetVisible(Window, false) 
    Faggio = guiCreateButton(9, 96, 117, 33, "Faggio", false, Window) 
    Perennial = guiCreateButton(9, 131, 117, 35, "Perennial", false, Window) 
    Walton = guiCreateButton(9, 169, 118, 34, "Walton", false, Window) 
    Tampa = guiCreateButton(9, 206, 118, 34, "Tampa", false, Window) 
    AutoWahlenLabel = guiCreateLabel(30, 57, 139, 15, "Bitte wähle ein Auto aus", false, Window) 
    Abbrechen = guiCreateButton(10, 288, 177, 29, "Abbrechen", false, Window) 
    OderMochtestDu = guiCreateLabel(39, 269, 117, 15, "Oder möchtest du...", false, Window) 
    lable1 = guiCreateLabel(131, 104, 52, 15, "500$", false, Window) 
    guiLabelSetColor(lable1, 23, 132, 5) 
    PerennialPreis = guiCreateLabel(131, 141, 53, 15, "2000$", false, Window) 
    guiLabelSetColor(PerennialPreis, 23, 132, 5) 
    WaltonPreis = guiCreateLabel(132, 181, 55, 15, "1500$", false, Window) 
    guiLabelSetColor(WaltonPreis, 23, 132, 5) 
    TampaPreis = guiCreateLabel(131, 218, 56, 15, "750$", false, Window) 
    guiLabelSetColor(TampaPreis, 23, 132, 5) 
      
    function Fake_Cars_show() 
        local IsWindowVisible = guiGetVisible(Window) 
        if (IsWindowVisible == true) then 
            guiSetVisible(Window, false) 
            guiSetInputEnabled(false) 
        elseif (IsWindowVisible == false) then 
            guiSetVisible(Window, true) 
            guiSetInputEnabled(true) 
        end 
    end 
      
    local myMarker = createMarker(-2615, 2262, 7.3, "cylinder", 1.0, 255, 0, 0, 150) 
      
    addEventHandler("onClientMarkerHit", myMarker, 
    function(player) 
        if getElementType(player) == "player" and player == localPlayer then 
            Fake_Cars_show() 
        end 
    end) 
      
function Buttons(state) 
    if state == "left" then 
            if source == Abbrechen then 
                Fake_Cars_show() 
            end 
            if source == Faggio then 
                money = getPlayerMoney() 
                if (money > 499) then 
                    triggerServerEvent("Faggio", getRootElement() ) 
                    takePlayerMoney(500) 
                else 
                    outputChatBox("Du hast nicht genügend Geld.") 
                end 
            end 
            if source == Perennial then 
                money = getPlayerMoney() 
                if (money > 1999) then 
                    triggerServerEvent("Perennial", getRootElement() ) 
                    takePlayerMoney(2000)    
                else 
                    outputChatBox("Du hast nicht genügend Geld.") 
                end 
            end 
            if source == Walton then 
                money = getPlayerMoney() 
                if (money > 1499) then 
                    triggerServerEvent("Walton", getRootElement() ) 
                    takePlayerMoney(1500) 
                else 
                    outputChatBox("Du hast nicht genügend Geld.") 
                end 
            end 
            if source == Tampa then 
            money = getPlayerMoney() 
                if (money > 749) then 
                    triggerServerEvent("Tampa", getRootElement() ) 
                    takePlayerMoney(750) 
                else 
                    outputChatBox("Du hast nicht genügend Geld.") 
                end 
            end 
        end 
   end 
  
    addEventHandler("onClientGUIClick", root, Buttons) 

Don't worry about the :0. It's just because it should sell the Motorcycle F a g g i o. And this Website doesn't allows this word.

Link to comment

And use triggerServerEvent right ;)

use this, and use source instead of thePlayer server side:

triggerServerEvent("your_event", getLocalPlayer() ) 

or use this so you don't need to change much on server-side just check, that if you used thePlayer as a function argument then use thePlayer in the function too, not ThePlayer.

triggerServerEvent("your_event", getLocalPlayer(), getLocalPlayer() ) 

Link to comment
Remember: when you use the function to take the money in the client side will be taking fake money in a way that if you want to be taking money to fully use the function to take the money in the server-side this was only just alert anyway your option .

Just in case you didnt understand this, you must trigger a server side event to take his money, or the money part is pointless

Link to comment
Remember: when you use the function to take the money in the client side will be taking fake money in a way that if you want to be taking money to fully use the function to take the money in the server-side this was only just alert anyway your option .

Just in case you didnt understand this, you must trigger a server side event to take his money, or the money part is pointless

Really?This is something new for me :mrgreen: .

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...