Jump to content

[Problem] Skin Cop for Vehicle


Jumper_Mych

Recommended Posts

1/2 part

policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
policeSkins = { [286]=true,[288]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if ( policeVehicle[getElementModel( source )] ) and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Doesn't Work :o

EDIT: Not Copy My Code!

Edited by Guest
Link to comment
policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
policeSkins = { [286]=true,[288]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (policeVehicle == source) and not policeSkins[getElementModel(player)] then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

This is really basic stuff, stop putting "Don't copy my code" and start learning more lua

Link to comment
policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
policeSkins = { [286]=true,[288]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementModel( source ) ==  getElementModel(policeVehicle) ) and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment

For Police

policeVehicle = createVehicle ( 426, 2401.4436035156, 76.328956604004, 25.292650222778, 0, 0, 90 ) 
policeSkins = { [286]=true,[288]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementModel( source ) ==  getElementModel(policeVehicle) ) and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

For medic

medicVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
medicSkins = { [275]=true,[277]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementModel( source ) ==  getElementModel(medicVehicle) ) and ( not medicSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a medic!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

two same id vehicle so two type and other skin:

You're not a cop! 
You're not a medic! 

and change skin to cop and enter to Cop Vehicle

You're not a medic! 

Connect id vehicle, to separation medic and police.

If don't u understand. i work rec monitoring and Add Youtube. some you know

Link to comment
policeVehicle = createVehicle ( 426, 2401.4436035156, 76.328956604004, 25.292650222778, 0, 0, 90 ) 
policeSkins = { [286]=true,[288]=true } 
medicVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
medicSkins = { [275]=true,[277]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementModel( source ) ==  getElementModel(policeVehicle) ) and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    elseif(getElementModel( source ) ==  getElementModel(medicVehicle) ) and ( not medicSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a medic!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Try that.

Link to comment
policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
setElementData(policeVehicle,"vehicle","police") 
policeSkins = { [286]=true,[288]=true } 
  
medicVehicle = createVehicle ( 426, 2401.4436035156, 76.328956604004, 25.292650222778, 0, 0, 90 ) 
setElementData(medicVehicle,"vehicle","medic") 
medicSkins = { [275]=true,[277]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementData(source, "vehicle" ) == "police") and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
    if (getElementData(source, "vehicle" ) == "medic") and ( not medicSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a medic!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment
policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) 
setElementData(policeVehicle,"vehicle","police") 
policeSkins = { [286]=true,[288]=true } 
  
medicVehicle = createVehicle ( 426, 2401.4436035156, 76.328956604004, 25.292650222778, 0, 0, 90 ) 
setElementData(medicVehicle,"vehicle","medic") 
medicSkins = { [275]=true,[277]=true } 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementData(source, "vehicle" ) == "police") and ( not policeSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a cop!", player ) 
        cancelEvent() 
    end 
    if (getElementData(source, "vehicle" ) == "medic") and ( not medicSkins[getElementModel( player )] ) then 
        outputChatBox ( "You're not a medic!", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Thanks you! That My Topic is Very problem and hard work

Link to comment

2/2 part :mrgreen:

vehicle = createVehicle ( 496, 2425, -55, 27, 0, 0, 0 ) 
setElementData(vehicle,"vehicle","car") 
bes = getElementType ( vehicle ) == "Jumper_Mych" 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementData(source, "vehicle" ) == "car") and ( not bes[getElementModel( player )] ) then 
        outputChatBox ( "Vehicle owner: Jumper_Mych", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Doesn't work

Player Can't get vehicle for Jumper_Mych and "Vehicle owner: Jumper_Mych" A Nick Jumper_Mych can enter vehicle. and Jumper_mych is in the vehicle ped can enter sit in vehicle.

Link to comment

doesn't work

vehicle = createVehicle ( 496, 2425, -55, 27, 0, 0, 0 ) 
setElementData(vehicle,"vehicle","car") 
bes = setPlayerName ( car, "Jumper_Mych" ) 
  
function enterVehicle ( player, seat, jacked ) 
    if (getElementData(source, "vehicle" ) == "car") and ( not bes[getPlayerName( player )] ) then 
        outputChatBox ( "Vehicle owner: Jumper_Mych", player ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

I think that already 6 times but not help

[09:45:13] ERROR: vehicle\mod8.lua:6: attempt to index global 'bes' (a boolean value) 

Error

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