Sky Posted January 11, 2008 Share Posted January 11, 2008 (edited) I have wondered whether could ensure that the scripts such as a barrel ion, the script bomber and the other can be used by just 1 nickname mine. What is the code was inserted into each script plz? IF this is not possible, is what can ensure that only my nickname can use this script: -- Client file -- First off, we need this to track the mouse being on or not mouseon = 0 -- We use functions in order to control the mouse functionality, so we can track our own variables function ActivateMouse() -- We set the mouse to active, and give them a message. mouseon = 1 showCursor( true ) -- outputChatBox( "Click to explode somewhere. Press b again to stop." ) end function DeactivateMouse() -- We hide the mouse, and tell them about it. mouseon = 0 showCursor( false ) -- outputChatBox( "Bomb mode deactivated." ) end function keydown() -- The key is the bomb one so we'll check whether to activate or deactivate. if ( mouseon == 0 ) then ActivateMouse() else DeactivateMouse() end end -- Bind the key. --bindKey( "b", "down", keydown ) function startup() -- -- At startup, we'll bind the key. outputChatBox( "Startup." ) bindKey( "b", "down", keydown ) outputChatBox( "Key binded. Press b to start bomber mode, and click to explode." ) end addEventHandler("onClientResourceStart", getRootElement(), startup) function commands( commandName, arg, arg2 ) -- This is like a mastercmd. if( arg == "start" ) then startup() elseif( arg == "keydown" ) then keydown() outputChatBox( "key down." ) elseif( arg == "mouse" ) then if( arg2 == "on" ) then ActivateMouse() outputChatBox( "Mouse activated." ) else DeactivateMouse() outputChatBox( "Mouse deactivated." ) end else outputChatBox( "Bomber script is active. (c) tomozj 2008" ) outputChatBox( "USAGE: /bomber [start/keydown/mouse] [on/off]" ) end end addCommandHandler("bomber", commands, arg, arg2) function mousehandler( button, state, absolouteX, absolouteY, worldX, worldY, worldZ ) -- When the mouse is clicked, we'll check the button and if need be, call the server script to create the explosion. if ( state == "down" ) and ( mouseon == 1 ) then triggerServerEvent( "bomb", getRootElement(), worldX, worldY, worldZ, source ) -- Optional message -- outputChatBox( "Kaboom!" ) DeactivateMouse() end end -- We call our mousehandler event when the user clicks the mouse. addEventHandler( "onClientClick", getRootElement(), mousehandler ) Thx . Edited January 11, 2008 by Guest Link to comment
[email protected] Posted January 11, 2008 Share Posted January 11, 2008 a certain pseudo? Link to comment
Sky Posted January 11, 2008 Author Share Posted January 11, 2008 i have edit bad traductor Link to comment
Guest Posted January 11, 2008 Share Posted January 11, 2008 - Sky tu as perdu... mwahaha ^^ Met en français ce que tu voulais mettre comme titre - Sky you have wasted... French writing what you would like to put the title:) Link to comment
[email protected] Posted January 12, 2008 Share Posted January 12, 2008 Well if you want to match it to your playername, then you can simply do getClientName( aPlayer ), and verify whether that is or is not your playername. (client side this is getPlayerName( aPlayer ) I think), but there is much more secure ways of implementing some sort of identification. It would depend on what you really want to have. And a side-note: the script you "quoted" is copyrighted, you probably need to get permission from it's creator to use it Link to comment
Cloudhunter Posted January 12, 2008 Share Posted January 12, 2008 Locking it to your nickname is insecure. It'd be much better to restrict the resource to your account in the ACL. Cloudy Link to comment
Sky Posted January 12, 2008 Author Share Posted January 12, 2008 Thank you for your answers, And therefore I imagine that I only want to use the script, I should add in her ACL : ? Thx. PS: Katalistix, pourquoi tu veut que je mette mon titre en francais ^^ ? Link to comment
[email protected] Posted January 12, 2008 Share Posted January 12, 2008 Thank you for your answers,And therefore I imagine that I only want to use the script, I should add in her ACL : ? Thx. PS: Katalistix, pourquoi tu veut que je mette mon titre en francais ^^ ? What you should do is to make sure you get yourself an ACL account if you haven't got it already (in the form of: user."name"). Then you can loop through all players and get the accounts they are logged in to. If their account matches with your user."name" account, then he/she is identified as you. Obviously you should login to your own account to make this work Ok, that may sound vague, so here is an example I made for my own scripts. This script checks whether a specific user is an admin or not: function isAdmin( playerObj ) -- get player account access... acName = getAccountName( getClientAccount( playerObj ) ) aclObj = "user."..acName -- retrieving all admin accounts... adminusers = aclGroupListObjects(aclGetGroup("Admin")) for akey, aname in ipairs(adminusers) do if (aclObj == aname) then return true -- if player's account username belongs to an admin's account, we found what we wanted to know. playerObj is an admin. end -- loop ends as soon as a match is found (on returning a function value) end return false -- player's account is not an admin account. end In your situation you do not need the loop because you want to match 1 name with a pre-defined account (but you must still loop through every player on the server and execute this function per player), you do not have to check ALL adminaccounts for matches (like I had to do), only the one you wanted, your code would look something like this: function isMe( playerObj ) -- get player account access... acName = getAccountName( getClientAccount( playerObj ) ) aclObj = "user."..acName -- retrieving all admin accounts... myAccount = aclGet("user.myName") -- myName is your account username if( aclObj == myAccount ) then return true -- player's account is your account. else return false -- player's account is not your account end end This function should return true if the player is logged into your account, and false if your player is not logged in to your account. Link to comment
Sky Posted January 12, 2008 Author Share Posted January 12, 2008 You do not understand, I would like to know if I can een fair so that only my nickname can use this script. And including: how do you make so that only my nickname can be used to script? Thx. Link to comment
[email protected] Posted January 12, 2008 Share Posted January 12, 2008 You do not understand, I would like to know if I can een fair so that only my nickname can use this script.And including: how do you make so that only my nickname can be used to script? Thx. Ok, now this I do not understand "een fair"? "only my nickname can be used to script"?, does this mean that only you can... use commands in this script or... what do you mean? Link to comment
Sky Posted January 12, 2008 Author Share Posted January 12, 2008 Ok, I will try to better explain: i want add in a script something for that there is only me who can use the script I am now talking . Example : in the script : -- Client file -- First off, we need this to track the mouse being on or not mouseon = 0 -- We use functions in order to control the mouse functionality, so we can track our own variables function ActivateMouse() -- We set the mouse to active, and give them a message. mouseon = 1 showCursor( true ) -- outputChatBox( "Click to explode somewhere. Press b again to stop." ) end function DeactivateMouse() -- We hide the mouse, and tell them about it. mouseon = 0 showCursor( false ) -- outputChatBox( "Bomb mode deactivated." ) end function keydown() -- The key is the bomb one so we'll check whether to activate or deactivate. if ( mouseon == 0 ) then ActivateMouse() else DeactivateMouse() end end -- Bind the key. --bindKey( "b", "down", keydown ) function startup() -- -- At startup, we'll bind the key. outputChatBox( "" ) bindKey( "b", "down", keydown ) outputChatBox( "" ) end addEventHandler("onClientResourceStart", getRootElement(), startup) function commands( commandName, arg, arg2 ) -- This is like a mastercmd. if( arg == "start" ) then startup() elseif( arg == "keydown" ) then keydown() outputChatBox( "key down." ) elseif( arg == "mouse" ) then if( arg2 == "on" ) then ActivateMouse() outputChatBox( "Mouse activated." ) else DeactivateMouse() outputChatBox( "Mouse deactivated." ) end else outputChatBox( "Bomber script is active. (c) tomozj 2008" ) outputChatBox( "USAGE: /bomber [start/keydown/mouse] [on/off]" ) end end addCommandHandler("bomber", commands, arg, arg2) function mousehandler( button, state, absolouteX, absolouteY, worldX, worldY, worldZ ) -- When the mouse is clicked, we'll check the button and if need be, call the server script to create the explosion. if ( state == "down" ) and ( mouseon == 1 ) then triggerServerEvent( "bomb", getRootElement(), worldX, worldY, worldZ, source ) -- Optional message -- outputChatBox( "Kaboom!" ) DeactivateMouse() end end -- We call our mousehandler event when the user clicks the mouse. addEventHandler( "onClientClick", getRootElement(), mousehandler ) Everyone can use this script when he is activated .. I want that just me can use this script when he is activated ! Thx . Link to comment
[email protected] Posted January 12, 2008 Share Posted January 12, 2008 Well, I think that is exactly what I posted around 3-4 posts above this one...: function isMe( playerObj ) -- get player account access... acName = getAccountName( getClientAccount( playerObj ) ) aclObj = "user."..acName -- retrieving all admin accounts... myAccount = aclGet("user.[b]myName[/b]") -- myName is your account username if( aclObj == myAccount ) then return true -- player's account is your account. else return false -- player's account is not your account end end Just replace myName, in "user.myName" with your account-login name (on your server). And in add a check in the script whether isMe( aPlayer ) returns true or not (aPlayer should be the player pressing the key then) I am not sure if this would work, but for example: function startup() [b] if( isMe( getLocalPlayer() ) ) then[/b] -- -- At startup, we'll bind the key. outputChatBox( "" ) bindKey( "b", "down", keydown ) outputChatBox( "" ) [b] end[/b] end This should only bind the b-key to a player, if that player is you (since it's a client-side script). Note: this only works if you are logged into your server-account, autologin should be enabled for that to work, but you can also do this check later in the script execution.. for example: when the key is pressed (this means in the function keydown() ) And.. why are you asking the same question in multiple topics? (see: viewtopic.php?f=91&t=21301&p=268892#p268892 ) 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