Jump to content

[HELP] VIP


TheBull

Recommended Posts

Helloo.

I've tried to make a script for playing musing for vip players only ,it's not working since i added getPlayerAccount,I really need you're help,

Here is my code :

Server :

function nyanCommand ( playerSource, commandName ) 
  
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
           triggerClientEvent (source,  "onNyanCat", root )   
    local theTriggerer = getPlayerName ( playerSource ) 
    triggerClientEvent ( "onNyanCat", getRootElement() ) 
    outputChatBox ( theTriggerer .. "#E45800 Is a Nyan Cat !", getRootElement(), 255, 255, 255, true ) 
  
    end 
  
function foolsCommand ( playerSource, commandName ) 
  
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
           triggerClientEvent (source,  "onFools", root ) 
    local theTriggerer = getPlayerName ( playerSource ) 
    triggerClientEvent ( "onFools", getRootElement() ) 
    outputChatBox ( theTriggerer .. "#E45800 Is Killing Fools!", getRootElement(), 255, 255, 255, true ) 
  
end 
  
  
addCommandHandler ( "nyan", nyanCommand ) 
addCommandHandler ( "fools", foolsCommand ) 
  

Client :

function nyan () 
    stopSound ( sound ) 
    sound = playSound("Nyan.mp3") 
    setSoundVolume(sound, 1) 
  
end 
  
function fools () 
    stopSound ( sound ) 
    sound = playSound("Killingfools.mp3") 
    setSoundVolume(sound, 1) 
end 
  
addEvent( "onNyanCat", true ) 
addEventHandler( "onNyanCat", getRootElement(), nyan ) 
  
addEvent( "onFools", true ) 
addEventHandler( "onFools", getRootElement(), fools ) 

And i disabled the Rhino's and hydra's and hunter's in my freeroam , and i want vip players be able to spawn these vehicles,could you give me what functions and events should i use?

Link to comment

acc it's not defined in your code.

add this line

local acc = getPlayerAccount(playerSource) 

and replace source with playerSource.

also you need to check if the player isLogged in or not

if acc and not isGuestAccount(acc) then 
-- Your code 
end  

Link to comment
Still not working , ERROR : 'end' expected (to close 'function' at line 13) near .

add end at the end of your code.

Example:

-- Server side

function nyanCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then  
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        local theTriggerer = getPlayerName ( playerSource ) 
        if commandName == "nyan" then 
                triggerClientEvent (playerSource,  "playMusicEvent", playerSource,"nyan" )   
                outputChatBox ( theTriggerer .. "#E45800 Is a Nyan Cat !", getRootElement(), 255, 255, 255, true ) 
            elseif commandName == "fools" then 
                triggerClientEvent (playerSource,  "playMusicEvent", playerSource,"fools" )   
                outputChatBox ( theTriggerer .. "#E45800 Is Killing Fools!", getRootElement(), 255, 255, 255, true ) 
            end  
        end  
    end 
end  
addCommandHandler ( "nyan", nyanCommand ) 
addCommandHandler ( "fools", nyanCommand) 

-- Client side

function playMusic (songName) 
    if sound and isElement(sound) then  
        stopSound(sound) 
    end  
    if songName == "nyan" then  
        sound = playSound("Nyan.mp3") 
    elseif soungName == "fools" then  
        sound = playSound("Killingfools.mp3") 
    end  
    setSoundVolume(sound, 1) 
end 
addEvent("playMusicEvent", true ) 
addEventHandler("playMusicEvent", getRootElement(), playMusic ) 

sorry i'm using my phone.

Edited by Guest
Link to comment
Command (nyan) worked now i fixed the missing thing , but the command (fools) is still not working,and the error when i start the resource is : ERROR : Bad argument @ 'addCommandHandler' [Expected function at argument 2,got nil]

ah sorry i forgot to change the function name to nyanCommand.

-- from  
addCommandHandler ( "fools", foolsCommand ) 
--To 
addCommandHandler ( "fools", nyanCommand ) 

that's all

-- Server side

function nyanCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        local theTriggerer = getPlayerName ( playerSource ) 
        if commandName == "nyan" then 
                triggerClientEvent (playerSource,  "playMusicEvent", playerSource,"nyan" )   
                outputChatBox ( theTriggerer .. "#E45800 Is a Nyan Cat !", getRootElement(), 255, 255, 255, true ) 
            elseif commandName == "fools" then 
                triggerClientEvent (playerSource,  "playMusicEvent", playerSource,"fools" )   
                outputChatBox ( theTriggerer .. "#E45800 Is Killing Fools!", getRootElement(), 255, 255, 255, true ) 
            end 
        end 
    end 
end 
addCommandHandler ( "nyan", nyanCommand ) 
addCommandHandler ( "fools", nyanCommand) 
  

-- Client side

function playMusic (songName) 
    if sound and isElement(sound) then 
        stopSound(sound) 
    end 
    if songName == "nyan" then 
        sound = playSound("Nyan.mp3") 
    elseif soungName == "fools" then 
        sound = playSound("Killingfools.mp3") 
    end 
    setSoundVolume(sound, 1) 
end 
addEvent("playMusicEvent", true ) 
addEventHandler("playMusicEvent", getRootElement(), playMusic )  

Link to comment
function playMusic (songName) 
    if sound and isElement(sound) then 
        stopSound(sound) 
    end 
    if songName == "nyan" then 
        sound = playSound("Nyan.mp3") 
    elseif songName == "fools" then 
        sound = playSound("Killingfools.mp3") 
    end 
    setSoundVolume(sound, 1) 
end 
addEvent("playMusicEvent", true ) 
addEventHandler("playMusicEvent", getRootElement(), playMusic )  

It was soungName instead of songName.

Link to comment

Thank you guys for your help , I really appreciate that,one more question i disabled the Rhino's and hydra's and hunter's and jetpacks in my freeroam , and i want vip players be able to spawn these vehicles and get jetpacks,could you give me what functions and events should i use? I'm really sorry for asking alot , Once again thanks.

Link to comment

Like that. I only wrote root instead of playerSource

function nyanCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        local theTriggerer = getPlayerName ( playerSource ) 
        if commandName == "nyan" then 
                triggerClientEvent (root,  "playMusicEvent", root,"nyan" ) -- changed 
                outputChatBox ( theTriggerer .. "#E45800 Is a Nyan Cat !", getRootElement(), 255, 255, 255, true ) 
            elseif commandName == "fools" then 
                triggerClientEvent (root,  "playMusicEvent", root,"fools" )  -- changed 
                outputChatBox ( theTriggerer .. "#E45800 Is Killing Fools!", getRootElement(), 255, 255, 255, true ) 
            end 
        end 
    end 
end 
addCommandHandler ( "nyan", nyanCommand ) 
addCommandHandler ( "fools", nyanCommand) 

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