| Blockland Forums > Modification Help |
| Will this work? |
| (1/3) > >> |
| wizzlemanizzle:
ok, im trying to make an addon and... EDIT: just look at this PM: ok, so i am almost finished creating the script i set out to make happen, This is basically it, but when im done it wont KILL the players in the else category- if i am right, this will check all players on the server and (just for now it will kill) non admins and give a messageboxok to admins when someone says /killnonadmin. am i right? Function ServerCmdkillnonadmin(); { for(%i = 0; %i < clientGroup.getCount(); %i++) { %client = clientGroup.getObject(%i); if(%client.isAdmin || %C.isSuperAdmin || %c.isHost) { messageboxOK("There they go..."; "You were just saved by your administrative powers, congrats on still being here"); } else { %player = %client.player; %player.kill(); } } } |
| Red_Guy:
well, its a start, but there some problems. first: all "serverCmd" functions have the first argument as %client so yours needs to say: function ServerCmdkillnonadmin(%client) - 'Function' needs to be lowercased: 'function' - no semicolon ; at the end of a function Now that you have the serverCmd following the correct pattern, your assign a value to variable %client inside your function. While torque doesnt care if you do this, other languages will, and since you said your just learning, its a good idea to start learning good ways of coding. So with that - you need to change: %client = clientGroup.getObject(%i); to use something other than %client. try: %obj or %cl or something. next thing I see is this line: if(%client.isAdmin || %C.isSuperAdmin || %c.isHost) %client has a value (but we are changing the variable name) %C has no value %c also has no value again with the "best practice" %c and %C are the same as far as torque is concerned, but not all languages are that way, so keep things consistent, and use %C and %C or %c and %c what I think you meant was this: if(%client.isAdmin || %client.isSuperAdmin || %client.isHost) -- which will change when you rename %client to something else Next is this line: messageboxOK("There they go..."; "You were just saved by your administrative powers, congrats on still being here"); Torque will give you a syntax error on this. Do some searching on the forums to find an example to see how its used. Lastly %player = %client.player; %player.kill(); can be changed to: %client.player.kill(); does the same thing with less script. Good stuff: unlike a lot of posters, all your {} match, and your gramamar skills are working well. |
| wizzlemanizzle:
thankyou. i do beleive i wll take that wonderful advice and now i will lock this. whats more, i have a question for you, and im going to PM you right away |
| Red_Guy:
--- Quote from: wizzlemanizzle on March 28, 2011, 07:57:17 PM ---thankyou. i do beleive i wll take that wonderful advice and now i will lock this. whats more, i have a question for you, and im going to PM you right away --- End quote --- please post your question in the thread so others can learn too |
| wizzlemanizzle:
oh alright i would like to know the command to disconnect a player from the server. would it be %client.disconnect();? or what? also... |
| Navigation |
| Message Index |
| Next page |