Jump to content

Please Help !


CigareTTe~

Recommended Posts

Hello friends:

The player would start to spawn when the theft. But the resource is not working. :cry:

Codes:

local robberHouses = 
{ 
    { 801.40002441406, -1600.4000244141, 12.300000190735 }; 
    { 2102.6999511719, -1806.5999755859, 12.199999809265 }; 
    { 1194.5, -922.29998779297, 41.700000762939 }; 
} 
  
function unpackRobberHouses () 
    return unpack ( robberHouses [ math.random ( #robberHouses ) ] ) 
end 
  
function robson( player ) 
  destroyElement ( robhouseMarker ) 
  destroyElement ( robhouseBlip ) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), robson )   
  
addEventHandler ( "onPlayerSpawn", root, 
    function ( player ) 
       team = getPlayerTeam(player) 
       if (getTeamName(team) == "Criminals") then 
       triggerEvent ( "createHouseEvent", player ) 
     end 
end) 
  
addEvent ( "createHouseEvent", true ) 
function createHouses () 
    x, y, z = unpackRobberHouses () 
     robhouseMarker = createMarker ( x, y, z, "cylinder", 10, 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 
) 

Link to comment

You might have some other problems too, but your onPlayerSpawn event isn't good. The first argument is the X coordinate not the player, use source instead.

addEventHandler ( "onPlayerSpawn", root, 
    function ( ) 
       team = getPlayerTeam( source ) 
       if (getTeamName(team) == "Criminals") then 
       triggerEvent ( "createHouseEvent", source ) 
     end 
end) 

Or you don't even have to get the team if you do it so:

addEventHandler ( "onPlayerSpawn", root, 
    function ( _, _, _, _, team ) 
        if team and (getTeamName(team) == "Criminals") then 
            triggerEvent ( "createHouseEvent", source ) 
        end 
    end) 

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