Jump to content

Help with givePlayerMoney on seat 0


S3M

Recommended Posts

Fixed a lot of bugs, but I really do not want to see you giving up, you did a great job, please do not rely on us to finish this, you can do it:

client:

GUIEditor_Window = {} 
GUIEditor_Button = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"",true) 
guiSetAlpha(GUIEditor_Window[1],225) 
guiCreateStaticImage ( 0, 0, 1, 0.8,"imageicecream.png",true,GUIEditor_Window[1]) 
guiSetVisible(GUIEditor_Window[1],false) 
GUIEditor_Button[1] = guiCreateButton(0.52,0.85,0.45,0.1,"Buy $2",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0,0.85,0.45,0.1,"Don't want",true,GUIEditor_Window[1]) 
  
addEvent("showGUIwhoopie",true) 
addEventHandler("showGUIwhoopie",getRootElement(), 
function showGUIwhoopie() 
    guiSetVisible (GUIEditor_Window[1],true) 
    showCursor(true) 
end 
) 
  
addEvent("hideGUIwhoopie",true) 
addEventHandler("hideGUIwhoopie",getRootElement(), 
function () 
    guiSetVisible(GUIEditor_Window[1],false) 
    showCursor (false) 
end) 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function (player) 
    if (source == GUIEditor_Button[2]) then 
        guiSetVisible (GUIEditor_Window[1],false) 
        showCursor (false) 
    elseif (source == GUIEditor_Button[1]) then 
        money = getPlayerMoney (localPlayer) 
        if (money <= 2) then 
            outputChatBox ("You cant pay $2?",225,0,0) 
        else 
            triggerServerEvent("giveMoney", localPlayer) 
        end 
    end 
end) 

server:

whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
  
function showGUI(hitPlayer) 
    triggerClientEvent (hitPlayer,"showGUIwhoopie",getRootElement(),hitPlayer) 
end 
addEventHandler ("onMarkerHit",whoopieMarker,showGUI) 
  
addEventHandler("onMarkerLeave",whoopieMarker, 
function (leavePlayer) 
    triggerClientEvent(leavePlayer,"hideGUIwhoopie",leavePlayer) 
end) 
  
addEvent("giveMoney",true) 
addEventHandler("giveMoney",getRootElement(), 
function giveMoney() 
    outputChatBox ("You buy a Ice cream", source, 225, 225, 0) 
    takePlayerMoney(source, 2) 
    setElementHealth ( source, getElementHealth(source) + 20 ) 
end 
) 
  
-- Only Mr.Whoopie 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
function() 
    mrwhoopieSkin = { [264]=true } 
    mrwhoopieVehicle = { [423]=true } 
end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle[getElementModel ( source )] ) and ( not mrwhoopieSkin[getElementModel ( thePlayer )] ) and (seat == 0) then  
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
    else     
    if ( mrwhoopieVehicle[getElementModel ( source )] ) and ( mrwhoopieSkin[getElementModel ( thePlayer )] ) and (seat == 0) then  
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo(whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( getElementModel ( source ) == 423 ) then  
        destroyElement(blipwhoopie) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 

Link to comment
-- client side:
GUIEditor_Window = {} 
GUIEditor_Button = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"",true) 
guiSetAlpha(GUIEditor_Window[1],225) 
guiCreateStaticImage ( 0, 0, 1, 0.8,"imageicecream.png",true,GUIEditor_Window[1]) 
guiSetVisible(GUIEditor_Window[1],false) 
GUIEditor_Button[1] = guiCreateButton(0.52,0.85,0.45,0.1,"Buy $2",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0,0.85,0.45,0.1,"Don't want",true,GUIEditor_Window[1]) 
  
function showGUIwhoopie ( ) 
    guiSetVisible ( GUIEditor_Window[1], true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUIwhoopie", true ) 
addEventHandler ( "showGUIwhoopie", getRootElement(), showGUIwhoopie ) 
  
addEvent ( "hideGUIwhoopie", true ) 
addEventHandler ( "hideGUIwhoopie", getRootElement(), 
    function ( ) 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor ( false ) 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Button[2] ) then 
            guiSetVisible ( GUIEditor_Window[1], false ) 
            showCursor ( false ) 
        elseif ( source == GUIEditor_Button[1] ) then 
            local money = getPlayerMoney ( ) 
            if ( money >= 2 ) then 
                triggerServerEvent ( 'TakeAndGive', localPlayer ) 
            end 
        end 
    end 
) 

-- server side:

local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   else 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
        end 
    end 
) 

Wauw SolidSnake14 it works...

What can i say, BIG THX.. you want a kiss to?

This makes me happy. :P

Aaaah :roll: the code of Solidsnake14 are working, but i find a little problem.

Wen player enter other car with other skin then he say: Sell ice cream to earn money.

Thx.

Link to comment
-- client side:
GUIEditor_Window = {} 
GUIEditor_Button = {} 
  
GUIEditor_Window[1] = guiCreateWindow(0.3,0.2,0.4,0.5,"",true) 
guiSetAlpha(GUIEditor_Window[1],225) 
guiCreateStaticImage ( 0, 0, 1, 0.8,"imageicecream.png",true,GUIEditor_Window[1]) 
guiSetVisible(GUIEditor_Window[1],false) 
GUIEditor_Button[1] = guiCreateButton(0.52,0.85,0.45,0.1,"Buy $2",true,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(0,0.85,0.45,0.1,"Don't want",true,GUIEditor_Window[1]) 
  
function showGUIwhoopie ( ) 
    guiSetVisible ( GUIEditor_Window[1], true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUIwhoopie", true ) 
addEventHandler ( "showGUIwhoopie", getRootElement(), showGUIwhoopie ) 
  
addEvent ( "hideGUIwhoopie", true ) 
addEventHandler ( "hideGUIwhoopie", getRootElement(), 
    function ( ) 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor ( false ) 
    end 
) 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor_Button[2] ) then 
            guiSetVisible ( GUIEditor_Window[1], false ) 
            showCursor ( false ) 
        elseif ( source == GUIEditor_Button[1] ) then 
            local money = getPlayerMoney ( ) 
            if ( money >= 2 ) then 
                triggerServerEvent ( 'TakeAndGive', localPlayer ) 
            end 
        end 
    end 
) 

-- server side:

local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   else 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
        end 
    end 
) 

Wauw SolidSnake14 it works...

What can i say, BIG THX.. you want a kiss to?

This makes me happy. :P

Aaaah :roll: the code of Solidsnake14 are working, but i find a little problem.

Wen player enter other car with other skin then he say: Sell ice cream to earn money.

Thx.

Sorry, i think i got fix the text for now.

I use these lines from csmit195 added to Solidsnake14 code:

24.-- Only Mr.Whoopie 
25.addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
26.function() 
27.    mrwhoopieSkin = { [264]=true } 
28.    mrwhoopieVehicle = { [423]=true } 
29.end 
30.) 
31.  
32.function enterVehicle ( thePlayer, seat, jacked ) 
33.    if ( mrwhoopieVehicle[getElementModel ( source )] ) and ( not mrwhoopieSkin[getElementModel ( thePlayer )] ) and (seat == 0) then  
34.        setTimer ( blowVehicle, 6500, 1, source ) 
35.        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
36.    else     
37.    if ( mrwhoopieVehicle[getElementModel ( source )] ) and ( mrwhoopieSkin[getElementModel ( thePlayer )] ) and (seat == 0) then  
38.        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
39.        blipwhoopie = createBlipAttachedTo(whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
40.    end 
41.    end 
42.end 
43.addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
44.  
45.function removeBlipOnExit ( thePlayer, seat, jacked ) 
46.    if ( getElementModel ( source ) == 423 ) then  
47.        destroyElement(blipwhoopie) 
48.    end 
49.end 
50.addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  

Thx.

Link to comment

Just in case use this:

Solidsnakes fixed:

local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   elseif ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin == getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
        end 
    end 
) 

Link to comment
Just in case use this:

Solidsnakes fixed:

local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   elseif ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin == getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
        end 
    end 
) 

Thank you csmit195 (y)

Now i try to setSound3D on sell/bought. I put the next line into :lol: but i hear nothing, how to?.

What i do wrong?

Server:

addEvent ( 'TakeAndGive', true ) 
  
addEventHandler ( 'TakeAndGive', root , 
  
    function ( ) 
  
        local Driver = getVehicleController ( whoopieVehicle ) 
  
        if ( Driver ) then 
  
            givePlayerMoney ( Driver, 2 ) 
  
            takePlayerMoney ( source, 2 ) 
  
[color=#FF0000]            local x, y, z = getElementPosition(source)[/color] 
[color=#FF0000]            triggerClientEvent ( "triggoncash", getRootElement(), "x, y, z" )[/color] 
  
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
  
            outputChatBox ( "You sell some Ice cream and earn 2$", Driver, 225, 225, 0 ) 
            outputChatBox ( "You Bought an Ice cream of 2$", source, 225, 225, 0 ) 
else 
            outputChatBox ( "Whoopee is not in his car, wait till he comes back", source, 225, 225, 0 ) 
  
        end 
  
    end 
) 
  

Client:

function onCash ( x, y, z ) 
        local soundcash = playSound3D("cash.mp3", x, y, z, false)  
                      setSoundMaxDistance( soundcash,50 )  
                      setSoundVolume(soundcash, 0.5)  
end 
addEvent( "triggoncasH", true ) 
addEventHandler( "triggoncasH", getRootElement(), onCash ) 

Meta:

        <file src="cash.mp3" /> 

Thx.

Link to comment

----Server---

local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   elseif ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin == getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            triggerClientEvent(Driver, 'Sound', Driver ) 
            outputChatBox ( "You Have Sold some Ice cream and earned 2$", Driver, 225, 225, 0 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
            else 
            outputChatBox ( "Whoopee is not in his car, wait till he comes back", source, 225, 225, 0 ) 
        end 
    end 
) 

---ClientSide ---

addEvent('Sound', true) 
addEventHandler('Sound', root, 
function  ( ) 
    local sound = playSound("cash.mp3")  
    setSoundVolume(sound, 0.5) 
end 
) 

Link to comment
----Server---
local whoopieVehicle = createVehicle ( 423, 2433.6787109375, -1655.0888671875, 13.162685394287, 0, 0, 90 ) 
local whoopieMarker = createMarker ( 0, 0, 0, "arrow", 1, 255, 0, 0, 5 ) 
attachElements ( whoopieMarker, whoopieVehicle, 1.2, -0.35, 0.8 ) 
local mrwhoopieSkin = 264 
local mrwhoopieVehicle = 423 
  
addEventHandler ( 'onMarkerHit', whoopieMarker, 
    function ( Hit ) 
        if ( getElementType ( Hit ) == 'player' ) then 
            triggerClientEvent ( Hit,"showGUIwhoopie", Hit ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", whoopieMarker, 
    function ( leavePlayer ) 
        if ( getElementType ( leavePlayer ) == 'player' ) then 
            triggerClientEvent ( leavePlayer, "hideGUIwhoopie", leavePlayer ) 
        end 
    end 
) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin ~= getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( blowVehicle, 6500, 1, source ) 
        setTimer ( outputChatBox, 4000, 1, "You are not Mr.Whoopie, Car explode in few seconds.", thePlayer, 255, 0, 0 ) 
   elseif ( mrwhoopieVehicle == getElementModel ( source ) ) and ( mrwhoopieSkin == getElementModel ( thePlayer ) ) and ( seat == 0 ) then 
        setTimer ( outputChatBox, 4000, 1, "Sell ice creams to earn money.", thePlayer, 255, 0, 0 ) 
        blipwhoopie = createBlipAttachedTo ( whoopieVehicle,56, 2, 255, 0, 0, 255, 0, 200 ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", root, enterVehicle ) 
  
function removeBlipOnExit ( thePlayer, seat, jacked ) 
    if ( mrwhoopieVehicle == getElementModel ( source ) ) then 
        destroyElement ( blipwhoopie ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), removeBlipOnExit ) 
  
addEvent ( 'TakeAndGive', true ) 
addEventHandler ( 'TakeAndGive', root , 
    function ( ) 
        local Driver = getVehicleController ( whoopieVehicle ) 
        if ( Driver ) then 
            givePlayerMoney ( Driver, 2 ) 
            takePlayerMoney ( source, 2 ) 
            setElementHealth ( source, getElementHealth ( source ) + 20 ) 
            triggerClientEvent(Driver, 'Sound', Driver ) 
            outputChatBox ( "You Have Sold some Ice cream and earned 2$", Driver, 225, 225, 0 ) 
            outputChatBox ( "You Bought an Ice cream", source, 225, 225, 0 ) 
            else 
            outputChatBox ( "Whoopee is not in his car, wait till he comes back", source, 225, 225, 0 ) 
        end 
    end 
) 

---ClientSide ---

addEvent('Sound', true) 
addEventHandler('Sound', root, 
function  ( ) 
    local sound = playSound("cash.mp3")  
    setSoundVolume(sound, 0.5) 
end 
) 

This isnt posible with sound3D? Only Whoopee hears the cash sound not the player who buy.

But it works.

Thx Max+

Link to comment
No, Problem Have Fun With Your Script ,

Last question do al player on the map hear this sound or only by whoopee car.

it must be only around whoopy car.

i think not on this way right?:

Server:

            triggerClientEvent(root, 'Sound', root ) 

Client:

addEvent('Sound', true) 
  
addEventHandler('Sound', root, 
  
function  ( ) 
    local sound = playSound("cash.mp3")  
    setSoundVolume(sound, 0.5) 
    setSoundMaxDistance(sound, 50) 
end) 

Thx.

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