Monty Posted May 19, 2012 Share Posted May 19, 2012 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 ) Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 And what is the error? you're not explaining anything. Link to comment
Kenix Posted May 19, 2012 Share Posted May 19, 2012 setPlayerTeam ( localPlayer, robberTeam ) What this? addEventHandler ( "onClientPedDamage", resourceRoot, function () cancelEvent () end ) And this https://wiki.multitheftauto.com/wiki/Scr ... troduction Link to comment
Smart. Posted May 19, 2012 Share Posted May 19, 2012 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. Link to comment
Monty Posted May 19, 2012 Author Share Posted May 19, 2012 setPlayerTeam ( localPlayer, robberTeam ) What this? addEventHandler ( "onClientPedDamage", resourceRoot, function () cancelEvent () end ) And this https://wiki.multitheftauto.com/wiki/Scr ... troduction not working Link to comment
Kenix Posted May 19, 2012 Share Posted May 19, 2012 I showed you mistakes. You should fix it. Also i not understand what you want make? Explain please details. Link to comment
Genius Posted May 19, 2012 Share Posted May 19, 2012 (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 May 19, 2012 by Guest Link to comment
Smart. Posted May 19, 2012 Share Posted May 19, 2012 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. Link to comment
Monty Posted May 19, 2012 Author Share Posted May 19, 2012 so what's the full code??? Link to comment
Genius Posted May 19, 2012 Share Posted May 19, 2012 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! Link to comment
X-SHADOW Posted May 19, 2012 Share Posted May 19, 2012 --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 ) Link to comment
Smart. Posted May 19, 2012 Share Posted May 19, 2012 It feels like I'm getting ignored. The code will never work as the function unpackRobberHouses isn't generated anywhere. and just out of curiosity how did you manage to get parts of the code but not the whole script? Anyhow: https://community.multitheftauto.com/index.php?p= ... ls&id=4780 Link to comment
Monty Posted May 20, 2012 Author Share Posted May 20, 2012 @seb is it possible to remove the ped and set the team robber with a commandhandler? Link to comment
Smart. Posted May 20, 2012 Share Posted May 20, 2012 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 ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now