Jump to content

Luke_Ferrara

Members
  • Posts

    88
  • Joined

  • Last visited

Details

  • Gang
    The Ferrara Family

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Luke_Ferrara's Achievements

Transformer

Transformer (11/54)

0

Reputation

  1. No I want it to check if the player is already handcuffed so if they do /cuff twice it doesnt just say "officer cuffed criminal" it says "criminal is already handcuffed"
  2. now there is no point in my script, it is suppose to tell my cuff script if a player is cuffed, like if a cop does cuff twice the second tie it says player has already been cuffed and saved the officer a pair of handcuffs
  3. function isPlayerCuffed(other) local other, name = exports.players:getFromName( other ) if (other) then local test = getControlState(other, jump) outputDebugString("other not found") if test then return true end end return false end always returns false, i have a command that uses /cuff that toggles the control of jump and /uncuff enables jump again, however when you use /uncuff it says theier already uncuffed even when jump is disabled..... any ideas??
  4. I know it's like an object mover but how can I go about starting one just need a few tips guys just need a starting point een reading wiki nonstop just need someone with a little more experiance
  5. How can i get the faction rank of a player in mta paradise and use the result that's received. exports.factions:getFactionRank? I am not sure been looking around can;t find anything
  6. well I haven't been on Valhalla for a while but I was playing the other day and noticed when your about to perform a drive by the window rolls down and after searching wiki I was wondering if there was a function I missed...hows Valhalla do it then if it's impossible?
  7. How can I script car windows to roll up or down for realistic traits for my rp for drivebys ect.?
  8. local data = { } local function notify( element, to ) -- is loaded if data[ element ] then -- support for both single and multiple users if to then to = { [ to ] = true } else to = data[ element ].subscribers end -- easier local items = data[ element ].items -- send it to every reciever for value in pairs( to ) do triggerClientEvent( value, "syncItems", value, items ) end else -- not loaded, send no items triggerClientEvent( to, "syncItems", to ) end end local function getID( element ) if getElementType( element ) == "player" then return exports.players:getCharacterID( element ) end end local function load( element, force ) if isElement( element ) then local elementID = getID( element ) if elementID then if force or not data[ element ] or data[ element ].id ~= elementID then -- initalize a table for it data[ element ] = { ['items'] = { }, ['subscribers'] = { }, id = elementID } -- load items local i = exports.sql:query_assoc( "SELECT `index`, item, value, name FROM items WHERE owner = " .. elementID .. " ORDER BY `index` ASC" ) for key, value in ipairs( i ) do table.insert( data[ element ].items, value ) end -- player should get notified of his items if getElementType( element ) == "player" then data[ element ].subscribers[ element ] = true notify( element, element ) end return true end return true end return false, "Element has no unique ID" end return false, tostring( element ) .. " is no element" end local function subscribe( element, to ) -- Make sure we have an element to subscribe to if load( to ) then -- subscribe to the element data[ to ].subscribers[ element ] = true return true end return false, "Unable to load element" end function get( element ) if load( element ) then return data[ element ].items end end function give( element, item, value, name ) -- we need a base to work on if load( element ) then -- we need at least item and value if type( item ) == 'number' and ( type( value ) == "number" or type( value ) == "string" ) then -- name can be optional, though if it's not, we need to escape it name2 = "NULL" if name then name2 = "'" .. exports.sql:escape_string( tostring( name ) ) .. "'" else name = nil end -- we need to know our item index local index, error = exports.sql:query_insertid( "INSERT INTO items (owner, item, value, name) VALUES (" .. getID( element ) .. ", " .. item .. ", '%s', " .. name2 .. ")", value ) if index then -- add at the last position as a new item table.insert( data[ element ].items, { index = index, item = item, value = value, name = name } ) -- tell everyone who wants to know notify( element ) return true end return false, "MySQL Query failed" end return false, "Invalid Parameters" end return false, "Unable to load element" end function take( element, slot ) -- we need a base to work on if load( element ) then -- check for existance of the slot if data[ element ].items[ slot ] then -- only continue if we could delete it local success, error = exports.sql:query_free( "DELETE FROM items WHERE `index` = " .. data[ element ].items[ slot ].index ) if success then -- remove it from the table, shift following items to pos=pos-1 table.remove( data[ element ].items, slot ) -- tell everyone who wants to know notify( element ) -- we managed it return true end return false, "MySQL Query failed" end return false, "No such slot exists" end return false, "Unable to load element" end function has( element, item, value, name ) -- we need a base to work on if load( element ) then -- at least the item is needed if type( item ) == 'number' then -- check if he has it for key, v in ipairs( data[ element ].items ) do if v.item == item and ( not value or v.value == value ) and ( not name or v.name == name ) then return true, key, v end end return false -- nope, no error either end return false, "Invalid Parameters" end return false, "Unable to load element" end local function unload( element ) -- clear old references if data[ element ] then -- don't have any items data[ element ].items = nil -- tell everyone who cares notify( element ) -- delete data[ element ] = nil return true end return false, "Element has no loaded items" end local function unsubscribe( element, from ) if from then -- we need to have an actual item to unsubscribe from if load( from ) then -- remove our reference data[ from ].subscribers[ element ] = nil end return true else -- look through all saved items for key, value in pairs( data ) do -- remove subscriber reference if exists if value.subscribers[ element ] then value.subscribers[ element ] = nil end end end end addEventHandler( "onElementDestroy", root, function( ) unload( source ) end ) addEventHandler( "onPlayerQuit", root, function( ) unload( source ) unsubscribe( source ) end ) addEventHandler( "onCharacterLogin", root, function( ) load( source, true ) end ) addEventHandler( "onCharacterLogout", root, function( ) unload( source ) unsubscribe( source ) end ) addEvent( "loadItems", true ) addEventHandler( "loadItems", root, function( ) if source == client then if exports.players:isLoggedIn( source ) then load( source, true ) end end end ) addEventHandler( "onResourceStart", resourceRoot, function( ) if not exports.sql:create_table( 'items', { { name = 'index', type = 'int(10) unsigned', primary_key = true, auto_increment = true }, { name = 'owner', type = 'int(10) unsigned' }, { name = 'item', type = 'int(10) unsigned' }, { name = 'value', type = 'text' }, { name = 'name', type = 'text', null = true }, } ) then cancelEvent( ) return end end ) -- addEvent( "items:use", true ) addEventHandler( "items:use", root, function( slot ) if source == client then if exports.players:isLoggedIn( source ) then local item = get( source )[ slot ] if item then local id = item.item local value = item.value local name = item.name or getName( id )
×
×
  • Create New...