Jump to content

General Scripting Help


Nitride

Recommended Posts

i can't get this script to kick anyone :/

function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID )  
  
    if currentWeaponID == 38 or currentWeaponID == 36 or currentWeaponID == 35 or currentWeaponID == 37 then  
        outputChatBox ( getClientName (source) .. " was kicked for spawning a " .. getWeaponNameFromID ( currentWeaponID ), getRootElement(), 255,0,0 ) 
        kickPlayer(source) 
    end 
end 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 

Link to comment
  
function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) 
      
    if currentWeaponID == 38 or 36 or 35 or 37 then 
        kickPlayer(source) 
        outputChatBox ( getPlayerName(source) .. " was kicked for spawning a " .. getWeaponNameFromID ( currentWeaponID ), getRootElement(), 255,0,0 ) 
    end 
end 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 
  

That should work.

I changed getClientName -> getPlayerName

Also made a change in your if statement:

  
  if currentWeaponID == 38 or currentWeaponID == 36 or currentWeaponID == 35 or currentWeaponID == 37 then 
  

Changed to this:

  
if currentWeaponID == 38 or 36 or 35 or 37 then 
  

Edited by Guest
Link to comment
function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID )  
  
    if currentWeaponID == 38 or 36 or 35 or 37 then  
        outputChatBox ( getPlayerName (source) .. " was kicked for spawning a " .. getWeaponNameFromID ( currentWeaponID ), getRootElement(), 255,0,0 ) 
        kickPlayer(source) 
    end 
end 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 

Link to comment
  
function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID ) 
      
    if currentWeaponID == 38 or 36 or 35 or 37 then 
        kickPlayer(source) 
        outputChatBox ( getPlayerName(source) .. " was kicked for spawning a " .. getWeaponNameFromID ( currentWeaponID ), getRootElement(), 255,0,0 ) 
    end 
end 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) 
  

That should work.

I changed getClientName -> getPlayerName

Also made a change in your if statement:

  
  if currentWeaponID == 38 or currentWeaponID == 36 or currentWeaponID == 35 or currentWeaponID == 37 then 
  

Changed to this:

  
if currentWeaponID == 38 or 36 or 35 or 37 then 
  

i tried yours and now every weapon that spawns makes that announcement and it still doesn't kick :S

Link to comment

Oh yeah :)

Thats because you have to include the file in the acl.xml file

It needs to have admin rights to use the kickPlayer() function.

Open your acl.xml in C:\Program Files (x86)\MTA San Andreas 1.1\server\mods\deathmatch

                                         

Replace "NAME-OF-THE-RESOURCE" with your resource name

Another thing. When you are scripting, try to use /debugscript 3

- It can help you detect a lot of different problems. If you had used it to test this resource, you would have noticed the error: Access denied @ 'kickPlayer'

Link to comment
Oh yeah :)

Thats because you have to include the file in the acl.xml file

It needs to have admin rights to use the kickPlayer() function.

Open your acl.xml in C:\Program Files (x86)\MTA San Andreas 1.1\server\mods\deathmatch

                                         

Replace "NAME-OF-THE-RESOURCE" with your resource name

Another thing. When you are scripting, try to use /debugscript 3

- It can help you detect a lot of different problems. If you had used it to test this resource, you would have noticed the error: Access denied @ 'kickPlayer'

thanks man. it worked after i added it into the admin group and change it back to vehicleid

Link to comment

im busy making a non-admin base with auto doors but none of them want to open :(

Front gate co-ords

frontgateNM.jpg

Front gate NM

local theMarker = createMarker ( -1530.3000488281, 482.20001220703, 9.6999998092651, "cylinder", 0, 0, 255, 0) 
local gate = createObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 255, 0 ) 
-- create Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
if hasObjectPermissionTo( hitElement, "function.kickPlayer" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
if (getElementType(hitElement) == "vehicle" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

back gate co-ords

backgateNM.jpg

Back Gate NM

local theMarker = createMarker ( -1250.1999511719, 463.89999389648, 9.60000014697,  "cylinder", 10, 0, 0, 255, 0 ) 
local subwaygate = createObject (-1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
-- Make Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
if hasObjectPermissionTo( hitElement, "function.kickPlayer" ) then 
moveObject ( gate, 1500, -1701.7937011719, 689.03674316406, 24.037502288818, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
  
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

Link to comment

Backgate

local theMarker = createMarker ( -1250.1999511719, 463.89999389648, 9.60000014697,  "cylinder", 10, 0, 0, 255, 0 ) 
local subwaygate = createObject (-1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
-- Make Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( gate, 1500, -1701.7937011719, 689.03674316406, 24.037502288818, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
  
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

front gate

local theMarker = createMarker ( -1530.3000488281, 482.20001220703, 9.6999998092651, "cylinder", 0, 0, 255, 0) 
local gate = createObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 255, 0 ) 
-- Define Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
if (getElementType(hitElement) == "vehicle" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

Link to comment
  
local theMarker = createMarker ( -1250.1999511719, 463.89999389648, 9.60000014697,  "cylinder", 10, 0, 0, 255, 0 ) 
local subwaygate = createObject (-1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
-- Make Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( subwaygate , 1500, -1701.7937011719, 689.03674316406, 24.037502288818, 0, 0, 0 ) -- Changed 'gate' to 'subwaygate' 
end 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
  
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

  
local theMarker = createMarker ( -1530.3000488281, 482.20001220703, 9.6999998092651, "cylinder", 0, 0, 255, 0) 
local subwaygate = createObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 255, 0 ) -- Changed 'gate' to 'subwaygate' 
-- Define Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
if (getElementType(hitElement) == "vehicle" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

Try that.. Think it works not. I have commented the changed in the scripts.

Link to comment

@Charlie_Jefferson

Thanks a lot man :)

Front gate:

  
local theMarker = createMarker ( -1530.3000488281, 482.20001220703, 9.6999998092651, "cylinder", 0, 0, 255, 0) 
local subwaygate = createObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 255, 0 ) -- Changed 'gate' to 'subwaygate' 
-- Define Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
if (getElementType(hitElement) == "vehicle" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

Back Gate:

local theMarker = createMarker ( -1250.1999511719, 463.89999389648, 9.60000014697,  "cylinder", 10, 0, 0, 255, 0 ) 
local subwaygate = createObject (-1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
-- Make Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
moveObject ( subwaygate , 1500, -1701.7937011719, 689.03674316406, 24.037502288818, 0, 0, 0 ) -- Changed 'gate' to 'subwaygate' 
end 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
  
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 

Link to comment
Charly-man this is not your script.
im busy making a non-admin base with auto doors but none of them want to open :(

Front gate co-ords

Front gate NM

local theMarker = createMarker ( -1530.3000488281, 482.20001220703, 9.6999998092651, "cylinder", 0, 0, 255, 0) 
local gate = createObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 255, 0 ) 
-- create Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
if hasObjectPermissionTo( hitElement, "function.kickPlayer" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
if (getElementType(hitElement) == "vehicle" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1530.3000488281, 482.20001220703, 9.6999998092651, 0, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

back gate co-ords

Back Gate NM

local theMarker = createMarker ( -1250.1999511719, 463.89999389648, 9.60000014697,  "cylinder", 10, 0, 0, 255, 0 ) 
local subwaygate = createObject (-1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
-- Make Marker and Gate 
  
function openGate ( hitElement ) 
if (getElementType(hitElement) == "player" ) then 
if hasObjectPermissionTo( hitElement, "function.kickPlayer" ) then 
moveObject ( gate, 1500, -1701.7937011719, 689.03674316406, 24.037502288818, 0, 0, 0 ) 
end 
end 
addEventHandler( "onMarkerHit", theMarker, openGate ) 
-- Open Gate 
  
function closeGate ( leftElement ) 
if (getElementType(leftElement) == "player" ) then 
moveObject ( subwaygate, -1250.1999511719, 463.89999389648, 9.60000014697, 0, 0, 0 ) 
  
end 
end 
addEventHandler( "onMarkerLeave", theMarker, closeGate ) 
-- Close Gate 
  

https://community.multitheftauto.com/index.php?p= ... ils&id=707

Stealer, aren't you ?

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