Samking Posted August 29, 2018 Share Posted August 29, 2018 function enterVehicle (player, seat, jacked) local accName = getAccountName (getPlayerAccount (player) if not isObjectInACLGroup("user."..accName, aclGetGroup ( "VIP" )) and getElementModel(source) == 412 then cancelEvent() outputChatBox ( "you must be VIP to use this vehicle", player) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) help me in this Link to comment
Samking Posted August 29, 2018 Author Share Posted August 29, 2018 local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function findPlayer( namepart ) local targetPlayer = getPlayerFromName ( who ) if ( targetPlayer ) then return player end for _,player in pairs( getElementsByType 'player' ) do if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then return player end end return false end addCommandHandler( 'givemoney', function( source,_,player,amount ) local find = findPlayer( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end And this Link to comment
JeViCo Posted August 29, 2018 Share Posted August 29, 2018 could you explain more? What problems do you have in your code? Link to comment
Samking Posted August 29, 2018 Author Share Posted August 29, 2018 27 minutes ago, JeViCo said: could you explain more? What problems do you have in your code? In this code local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function findPlayer( namepart ) local targetPlayer = getPlayerFromName ( who ) if ( targetPlayer ) then return player end for _,player in pairs( getElementsByType 'player' ) do if string.find( string.gsub( getPlayerName( player ):lower( ),"#%x%x%x%x%x%x", "" ), namepart:lower( ), 1, true ) then return player end end return false end addCommandHandler( 'givemoney', function( source,_,player,amount ) local find = findPlayer( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end Bad srgument @'getPlayerFromName [Expected string at argument 1 , got nill] and this code function enterVehicle (player, seat, jacked) local accName = getAccountName (getPlayerAccount (player) if not isObjectInACLGroup("user."..accName, aclGetGroup ( "VIP" )) and getElementModel(source) == 412 then cancelEvent() outputChatBox ( "you must be VIP to use this vehicle", player) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) and this code is not working this spawn only car and give this car to those who is not VIP Link to comment
Dimos7 Posted August 29, 2018 Share Posted August 29, 2018 local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addCommandHandler( 'givemoney', function( source,_,player,amount ) local find = getPlayerFromPatrialName( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end try that Link to comment
Samking Posted August 29, 2018 Author Share Posted August 29, 2018 1 hour ago, Dimos7 said: local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addCommandHandler( 'givemoney', function( source,_,player,amount ) local find = getPlayerFromPatrialName( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end try that error attempt to call global 'getPlayerFromPartialName' <a nil value> Link to comment
Dimos7 Posted August 29, 2018 Share Posted August 29, 2018 local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addCommandHandler( 'givemoney', function( source,_,giveTo,amount ) local find = getPlayerFromPatrialName( giveTo) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end Link to comment
Samking Posted August 29, 2018 Author Share Posted August 29, 2018 6 minutes ago, Dimos7 said: local isPlayerInGroup, givemoney local function givemoneycommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addCommandHandler( 'givemoney', function( source,_,giveTo,amount ) local find = getPlayerFromPatrialName( giveTo) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end ) function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end sorry, but the error is still same. Link to comment
JeViCo Posted August 29, 2018 Share Posted August 29, 2018 function enterVehicle (player, seat) if getElementModel(source) == 412 and seat == 0 then local accName = getAccountName(getPlayerAccount (player)) if not isPlayerInGroup (player, "VIP") then cancelEvent() outputChatBox ( "you must be VIP to use this vehicle", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --------- addCommandHandler( 'givemoney', function( source,_,player,amount ) if amount then if isPlayerInGroup(source,"Admin") then local find = findPlayer( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end else if isPlayerInGroup (source, "VIP") then giveCash (source) else outputChatBox ("You must be VIP to use this command.", source,255,0, 0,true) end end end ) -- useful functions function findPlayer(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end @Samking Link to comment
Dimos7 Posted August 29, 2018 Share Posted August 29, 2018 (edited) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function givemoneycommand (player, cmd, giveTo, amount) local find = getPlayerFromPartialName(giveTo) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("VIP")) then if find then if amount then if getPlayerMoney(player) >= tonumber(amount) then takePlayerMoney(player, tonumber(amount)) givePlayerMoney(find, tonumber(amount)) outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),player,0,255,0 ) else outputChatBox('[givemoney]:You don't have that amount!', player, 255, 0, 0) end else outputChatBox( '[givemoney]:/'..cmd..'[playername][amount]!',player,255,0,0 ) end outputChatBox( '[givemoney]:Player not found!',player,255,0,0 ) end else outputChatBox ("You must be VIP to use this command.", player,255,0, 0,true) end end addCommandHandler("givemoney", givemoneycommand) Edited August 29, 2018 by Dimos7 Link to comment
Berko Posted August 29, 2018 Share Posted August 29, 2018 function enterVehicle (player, seat) if getElementModel(source) == 412 and seat == 0 then local accName = getAccountName(getPlayerAccount (player)) if not isPlayerInGroup (player, "VIP") then cancelEvent() outputChatBox ( "you must be VIP to use this vehicle", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --------- addCommandHandler( 'givemoney', function( source,_,player,amount ) if amount then if isPlayerInGroup(source,"Admin") then local find = findPlayer( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end else if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You must be VIP to use this command.", source,255,0, 0,true) end end end ) -- useful functions function findPlayer(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end Link to comment
Samking Posted August 29, 2018 Author Share Posted August 29, 2018 1 hour ago, JeViCo said: function enterVehicle (player, seat) if getElementModel(source) == 412 and seat == 0 then local accName = getAccountName(getPlayerAccount (player)) if not isPlayerInGroup (player, "VIP") then cancelEvent() outputChatBox ( "you must be VIP to use this vehicle", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --------- addCommandHandler( 'givemoney', function( source,_,player,amount ) if amount then if isPlayerInGroup(source,"Admin") then local find = findPlayer( player ) if find then if amount then -- If player type amount ( full command /givemoney [nickname][amount] ) givePlayerMoney( find,tonumber( amount ) ) -- give money for player outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) else -- player not type full command ( /givemoney [nickname][amount] ) outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) end else outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) end end else if isPlayerInGroup (source, "VIP") then giveCash (source) else outputChatBox ("You must be VIP to use this command.", source,255,0, 0,true) end end end ) -- useful functions function findPlayer(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then return true end end return false end @Samking Thanks 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now