Jump to content

Help! Hide Script


fairyoggy

Recommended Posts

Hello! Can you help me? How can I hide(or stop) the script for only one player? Example: the player connect in server and he does not see the necessary script but when player press the button "login" this script will be displayed or start (if can't just hide)

or how i can hide or stop script for players who are in a group (guest)

if isGuestAccount(getPlayerAccount(player)) then ... How?

 

Link to comment
  • Scripting Moderators
20 minutes ago, slapz0r said:

Hello! Can you help me? How can I hide(or stop) the script for only one player? Example: the player connect in server and he does not see the necessary script but when player press the button "login" this script will be displayed or start (if can't just hide)

or how i can hide or stop script for players who are in a group (guest)

if isGuestAccount(getPlayerAccount(player)) then ... How?

 

If you are about not downloading them for players you can use:

<script src="script.lua" type="client" cache="false"/>

In meta.xml

  • Like 1
Link to comment
57 minutes ago, majqq said:

If you are about not downloading them for players you can use:


<script src="script.lua" type="client" cache="false"/>

In meta.xml

I mean these resources are necessary, but hide or dont start for players who not login. and when they login this resource will be started or unhide

Edited by slapz0r
Link to comment
  • Scripting Moderators
7 hours ago, slapz0r said:

I mean these resources are necessary, but hide or dont start for players who not login. and when they login this resource will be started or unhide

Clientside scripts which have cache="false" will be not saved in player cache, but in RAM. So, still you can use them. I don't really understand you, can you be a more specific? You need to hide scripts/files or something else?

  • Like 1
Link to comment
12 hours ago, majqq said:

Clientside scripts which have cache="false" will be not saved in player cache, but in RAM. So, still you can use them. I don't really understand you, can you be a more specific? You need to hide scripts/files or something else?

Sorry for my bad english. I have 2 custom scripts (hud, radar). So if player join on server he sees these scripts (hud, radar) but that's not what i need. setPlayerHudComponentVisible( source, "all", false ) didn't work for that. I think because it's custom scripts. So I need to hide these 2 scripts for "onPlayerJoin" and when player  "onPlayerLogin" this scripts will be start. So if i try to use cache off and after "onPlayerLogin" this scripts will be download or start. These actions will help me?

Edited by slapz0r
Link to comment
18 hours ago, slapz0r said:

Sorry for my bad english. I have 2 custom scripts (hud, radar). So if player join on server he sees these scripts (hud, radar) but that's not what i need. setPlayerHudComponentVisible( source, "all", false ) didn't work for that. I think because it's custom scripts. So I need to hide these 2 scripts for "onPlayerJoin" and when player  "onPlayerLogin" this scripts will be start. So if i try to use cache off and after "onPlayerLogin" this scripts will be download or start. These actions will help me?

No, they won't help you, i have understood you want to start a custom script when the player has logged in

you will type your custom script codes inside a new function like this :

outputChatBox("Welcome to server"); -- This function will start when the script has downloaded

function out() -- but this function will not .
  outputChatBox("Welcome to server");
end

and the script name will be : mycustomhud and file name will be : hud.lua

 

so what do you need to do ?

you need to put the function inside your meta.xml file

like this :

<meta>
  <script src="hud.lua" type="client" />
  <export function="out" type="client"/>
</meta>

Then you will export the function to your login script, let us type a new code :

addEventHandler("onPlayerLogin",root,
  	function()
    	triggerClientEvent("onClientLogin",source);
   	end
);


-- Client


addEvent("onClientLogin",true);

function onClientLogin()
  --So , now you will type the export code to get a message ..
  exports["mycustomhud"]:out(); -- This will output a chat message 
  -- exports -- is export function
  -- mycustomhud -- is the name of your custom hud script
  -- out() is the function of the message in hud.lua file
end

addEventHandler("onClientLogin",root,onClientLogin);

They were just examples.

You can follow the steps and apply their in your scripts.

 

Edited by NX_CI
  • Like 1
Link to comment
16 hours ago, NX_CI said:

No, they won't help you, i have understood you want to start a custom script when the player has logged in

you will type your custom script codes inside a new function like this :


outputChatBox("Welcome to server"); -- This function will start when the script has downloaded

function out() -- but this function will not .
  outputChatBox("Welcome to server");
end

and the script name will be : mycustomhud and file name will be : hud.lua

 

so what do you need to do ?

you need to put the function inside your meta.xml file

like this :


<meta>
  <script src="hud.lua" type="client" />
  <export function="out" type="client"/>
</meta>

Then you will export the function to your login script, let us type a new code :


addEventHandler("onPlayerLogin",root,
  	function()
    	triggerClientEvent("onClientLogin",source);
   	end
);


-- Client


addEvent("onClientLogin",true);

function onClientLogin()
  --So , now you will type the export code to get a message ..
  exports["mycustomhud"]:out(); -- This will output a chat message 
  -- exports -- is export function
  -- mycustomhud -- is the name of your custom hud script
  -- out() is the function of the message in hud.lua file
end

addEventHandler("onClientLogin",root,onClientLogin);

They were just examples.

You can follow the steps and apply their in your scripts.

 

Your example not working(or i dont undestand), I tried to just make your example and nothing comes out. 

get out various errors(

1. call:failed to call "mycustomhud:out" [string "?"]

2. [server] OnClientLogin is deprecated and may not work in future versions.

Can you create working script like this example?

When player login a message appears in the chat.

 

Link to comment
12 minutes ago, slapz0r said:

ye, now it's work. I will try to work with these examples to solve my problems.

Can I have another question? I would like to bind key to open a chat, I mean when a player presses a button "T" appears text line

How can I do the same thing on another button?

You should create a new custom chatbox, i don't know is there another way or not.

but, for stay away from wrongs you will create a custom chatbox.

Edited by NX_CI
Link to comment
2 minutes ago, NX_CI said:

You must create a new custom chatbox, i don't know is there another way or not.

but, for stay away from wrongs you will create a custom chatbox.

so i can't use standard chatbox? just bind another key. I don't need to delete the old button.I just need to add another button to call the chat.

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