Jump to content

help me please


Recommended Posts

i have doubt in following script

  Quote

function teamName ( thePlayer )

local playerTeam = getPlayerTeam ( thePlayer )

local copTeam = getTeamName ( playerTeam )

if ( copTeam == "Cop" ) then

outputChatBox("Hello Cop")

end

end

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), teamName )

the console says it contain following errors

Bad 'player' pointer @ 'getPlayerTeam'(1) - Line:2

Bad 'argument @ 'getTeamName' - Line:3

help me i ll be thank ful

Link to comment
  gordliamjack said:
you havent defined cop!

i might be wrong because i use c++ not lua

What pills did you take? Even if you don't know Lua but C++ you should know what this code does and that "cop" has got nothing to do with those error messages. So, I assume you know some very basic stuff in C++ or just started to learn it. Also, don't scream at anyone if you're not 100% sure of what you're saying.

Pulsarkk, you attached teamName function to "onResourceStart" event but this event does not trigger function with player element as the first parameter. You have to pass "player" element to function getPlayerTeam.

Attach the function to some event that calls a function and passes player element to the call. What are you trying to do, anyway? Because it's hard to give you advice if we don't know what this code is supposed to do.

Link to comment

sorry to spam

local mg = createObject( 969, 1545, -1632, 12.5,0,0,90) 
local sg = createObject( 969, 1545, -1640, 12.5,0,0,90) 
local s2g = createObject( 969, 1545, -1624, 12.5,0,0,90) 
local marker = createMarker( 1545, -1627, 6.3, "cylinder", 12, 255, 255,255,0)   
local playerTeam = getPlayerTeam ( thePlayer ) 
local copTeam = getTeamName ( playerTeam ) 
     
gRoot = getRootElement () 
  
function MarkerHit ( hitPlayer, matchingDimension ) 
  
        if ( copTeam == "Cop" ) then 
            
         moveObject( mg, 1000, 1545, -1624, 12.5) 
      
        end   
end 
addEventHandler ( "onMarkerHit", gRoot, MarkerHit ) 
function MarkerLeave ( leavePlayer, matchingDimension ) 
  
        if ( copTeam == "Cop" ) then 
            
         moveObject( mg, 1000, 1545, -1624, 12.5) 
      
       end   
end 
addEventHandler ( "onMarkerLeave", gRoot, MarkerLeave ) 

this is the actual script it contains error

it says

Bad argument @ 'getPlayerTeam' -Line -5

Bad argument @ 'getTeamName' -Line -6

Link to comment

thePlayer isn't defined.

I'll make a small example for your markerHit function:

function MarkerHit ( hitPlayer, matchingDimension ) 
        local playerTeam = getPlayerTeam ( hitPlayer ) 
        local copTeam = getTeamName ( playerTeam ) 
  
        if ( copTeam == "Cop" ) then 
            
         moveObject( mg, 1000, 1545, -1624, 12.5) 
      
        end   
end 

Not tested, but I can't see why it shouldn't work. :P

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