Jump to content

robber error


Monty

Recommended Posts

Posted

hi it's me again... hi have a little problem with my script...

server-side:

function createRobberTeam () 
    robberTeam = createTeam ( "Robber", 250, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) 
  
function givePlayerJob ( ) 
    setPlayerTeam ( localPlayer, robberTeam ) 
end 
addCommandHandler ( "robber", givePlayerJob ) 
  
addEvent ( "givePlayerPay", true ) 
function givePlayerRobPay () 
    money = math.random ( 350, 1020 ) 
     givePlayerMoney ( source, money ) 
      outputChatBox ( "You succesfully robbed the house and made $" ..money, source ) 
       fadeCamera ( source, false, 1, 0, 0, 0 ) 
        setTimer ( fadeCamera, 1000, 1, source, true, 1 ) 
end 
addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) 

client-side:

addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) 
      robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) 
end 
addEventHandler ( "createHouseEvent", root, createHouses ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPay", localPlayer ) 
         destroyElement ( robhouseMarker ) 
           destroyElement ( robhouseBlip ) 
            triggerEvent ( "createHouseEvent", localPlayer ) 
             playSound ( "files/cash.mp3", false ) 
        end 
    end 
) 
  
addEventHandler ( "onClientPedDamage", resourceRoot, 
    function () 
        cancelEvent () 
    end 
) 

Posted

It's parts from one of my scripts.

The cancelEvent was meant to make the job ped immortal but he only took parts from it and never created the ped.

Posted

I showed you mistakes. You should fix it. :wink:

Also i not understand what you want make? Explain please details.

Posted (edited)
hi it's me again... hi have a little problem with my script...

server-side:

function createRobberTeam () 
    robberTeam = createTeam ( "Robber", 250, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) 
  
function givePlayerJob ( thePlayer) 
    setPlayerTeam ( thePlayer, robberTeam ) 
end 
addCommandHandler ( "robber", givePlayerJob ) 
  
addEvent ( "givePlayerPay", true ) 
function givePlayerRobPay () 
    money = math.random ( 350, 1020 ) 
     givePlayerMoney ( source, money ) 
      outputChatBox ( "You succesfully robbed the house and made $" ..money, source ) 
       fadeCamera ( source, false, 1, 0, 0, 0 ) 
        setTimer ( fadeCamera, 1000, 1, source, true, 1 ) 
end 
addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) 

client-side:

addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) 
      robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) 
end 
addEventHandler ( "createHouseEvent", root, createHouses ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPay", localPlayer ) 
         destroyElement ( robhouseMarker ) 
           destroyElement ( robhouseBlip ) 
            triggerEvent ( "createHouseEvent", localPlayer ) 
             playSound ( "files/cash.mp3", false ) 
        end 
    end 
) 
  
addEventHandler ( "onClientPedDamage", resourceRoot, 
    function () 
        cancelEvent ( createHouseEvent ) 
    end 
) 

localPlayer is not SERVER Element

Edited by Guest
Posted
x, y, z = unpackRobberHouses () 

wont work as you never made the unpackRobberHouses function. You better use the whole script I made or learn what you're doing.

Posted
hi it's me again... hi have a little problem with my script...

server-side:

function createRobberTeam () 
    robberTeam = createTeam ( "Robber", 250, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) 
  
function givePlayerJob ( thePlayer) 
    setPlayerTeam ( thePlayer, robberTeam ) 
end 
addCommandHandler ( "robber", givePlayerJob ) 
  
addEvent ( "givePlayerPay", true ) 
function givePlayerRobPay () 
    money = math.random ( 350, 1020 ) 
     givePlayerMoney ( source, money ) 
      outputChatBox ( "You succesfully robbed the house and made $" ..money, source ) 
       fadeCamera ( source, false, 1, 0, 0, 0 ) 
        setTimer ( fadeCamera, 1000, 1, source, true, 1 ) 
end 
addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) 

client-side:

addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) 
      robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) 
end 
addEventHandler ( "createHouseEvent", root, createHouses ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPay", localPlayer ) 
         destroyElement ( robhouseMarker ) 
           destroyElement ( robhouseBlip ) 
            triggerEvent ( "createHouseEvent", localPlayer ) 
             playSound ( "files/cash.mp3", false ) 
        end 
    end 
) 
  
addEventHandler ( "onClientPedDamage", resourceRoot, 
    function () 
        cancelEvent ( createHouseEvent ) 
    end 
) 

localPlayer is not SERVER Element

Its full code!

Posted
--serverSide 
function createRobberTeam () 
    robberTeam = createTeam ( "Robber", 250, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) 
  
function givePlayerJob ( ) 
    setPlayerTeam ( source, robberTeam ) 
end 
addCommandHandler ( "robber", givePlayerJob ) 
  
addEvent ( "givePlayerPay", true ) 
  
function givePlayerRobPay () 
    money = math.random ( 350, 1020 ) 
     givePlayerMoney ( source, money ) 
      outputChatBox ( "You succesfully robbed the house and made $" ..money, source ) 
       fadeCamera ( source, false, 1, 0, 0, 0 ) 
        setTimer ( fadeCamera, 1000, 1, source, true, 1 ) 
end 
addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) 
  
--ClientSide 
  
addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) 
      robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) 
end 
addEventHandler ( "createHouseEvent", root, createHouses ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPay", localPlayer ) 
         destroyElement ( robhouseMarker ) 
           destroyElement ( robhouseBlip ) 
            triggerEvent ( "createHouseEvent", localPlayer ) 
             playSound ( "files/cash.mp3", false ) 
        end 
    end 
) 
  
function pro () 
cancelEvent()  
end 
addEventHandler ( "onClientPedDamage", getRootElement(), pro ) 

Posted

maybe, cba thinking atm:

client:

--[[ 
  
Developer: Sebastian 'seb' Cronberg 
Rights: All rights reserved by the developer (c) 2012 
File: robber_client.lua 
  
]] 
local robberHouses = 
{ 
    { 1231, 123, 123 }; -- change to your values. 
} 
  
function unpackRobberHouses () 
    return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) 
end 
  
addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 3, 255, 51, 102, 85, localPlayer ) 
     robhouseBlip = createBlipAttachedTo ( robhouseMarker, 32, localPlayer ) 
end 
addEventHandler ( "createHouseEvent", root, createHouses ) 
  
addEventHandler ( "onClientMarkerHit", root, 
    function ( hitElement ) 
        if ( source == robhouseMarker and not isPedInVehicle ( localPlayer ) and hitElement == localPlayer ) then 
            triggerServerEvent ( "givePlayerPay", localPlayer ) 
        destroyElement ( robhouseMarker ) 
        destroyElement ( robhouseBlip ) 
        triggerEvent ( "createHouseEvent", localPlayer ) 
        playSound ( "files/cash.mp3", false ) 
        end 
    end 
) 
  
function triggerServer () 
    triggerEvent ( "createHouseEvent", localPlayer ) 
    triggerServerEvent ( "robberJobAccepted", localPlayer ) 
end 
addCommandHandler ( "criminal", triggerServer ) 

server:

--[[ 
  
Developer: Sebastian 'seb' Cronberg 
Rights: All rights reserved by the developer (c) 2012 
File: ronbber_server.lua 
  
]] 
  
function createRobberTeam () 
    robberTeam = createTeam ( "Robber", 250, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, createRobberTeam ) 
  
addEvent ( "robberJobAccepted", true ) 
function givePlayerJob ( ) 
    setPlayerTeam ( source, robberTeam ) 
end 
addEventHandler ( "robberJobAccepted", root, givePlayerJob ) 
  
addEvent ( "givePlayerPay", true ) 
function givePlayerRobPay () 
    money = math.random ( 350, 1020 ) 
     givePlayerMoney ( source, money ) 
     outputChatBox ( "You succesfully robbed the house and made $" ..money, source ) 
     fadeCamera ( source, false, 1, 0, 0, 0 ) 
     setTimer ( fadeCamera, 1000, 1, source, true, 1 ) 
end 
addEventHandler ( "givePlayerPay", root, givePlayerRobPay ) 

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