Raised This Month: $ Target: $400
 0% 

All players.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 09-09-2005 , 22:13   All players.
Reply With Quote #1

I'm trying to make as_disco_all work, as_disco works. I think it's something to do with i and set task or something.

Also, I know there's a way to make this shorter. I tried putting

if(containi(player,"@all")) {
set_task(0.3,"allfunc",i,_,_,"b")
}

(not exactly) and junk. Although my main priority is to get as_disco all to work.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Admin System" #define VERSION "0.1" #define AUTHOR "DahVid" new players[32],num,i //use these one too many time! :) public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("as_disco","disco",ADMIN_BAN,"as_disco <user>")     register_clcmd("as_disco_all","disco_allstart",ADMIN_BAN,"as_discoall (disco's all users!") } public disco(id) {     if(!is_user_admin(id)) {         console_print(id,"[ASMod]Sorry, this command is for administrators ONLY!")         return PLUGIN_HANDLED     }     new player[33]     read_argv(1,player,32)     new target=cmd_target(id,player,9)     if(!is_user_connected(target)) {         console_print(id,"[ASMod]The player you have entered has not been found in the server or he has immunity.")     }     //Thanks to GHW_Chronic for the idea!     set_task(0.3,"disco_start",target,_,_,"b")         return PLUGIN_CONTINUE } public disco_start(target) {     if(!is_user_connected(target)) {         return PLUGIN_HANDLED     }     new red,green,blue,alpha     red=random_num(0,255)     green=random_num(0,255)     blue=random_num(0,255)     alpha=random_num(30,220)         message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},target)     write_short(~0)     write_short(~0)     write_short(1<<12)     write_byte(red)     write_byte(green)     write_byte(blue)     write_byte(alpha)     message_end()         set_user_rendering(target,kRenderFxGlowShell,red,green,blue,kRenderTransAlpha,255)         return PLUGIN_CONTINUE } public disco_allstart() {     get_players(players,num)     for(i=0;i<=num;i++) {         set_task(0.3,"disco_all",i,_,_,"b")     } } public disco_all() {     get_players(players,num)     for(i=0;i<=num;i++) {         if(!is_user_connected(i)) {             return PLUGIN_HANDLED         }         new red,green,blue,alpha         red=random_num(0,255)         green=random_num(0,255)         blue=random_num(0,255)         alpha=random_num(30,220)                 message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},i)         write_short(~0)         write_short(~0)         write_short(1<<12)         write_byte(red)         write_byte(green)         write_byte(blue)         write_byte(alpha)         message_end()                 set_user_rendering(i,kRenderFxGlowShell,red,green,blue,kRenderTransAlpha,255)     }     return PLUGIN_HANDLED }
pdoubleopdawg is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-09-2005 , 22:53  
Reply With Quote #2

a)
Code:
if(!is_user_connected(target)) {     console_print(id,"[ASMod]The player you have entered has not been found in the server or he has immunity.") }
This is unnecessary, cmd_target does this for you. Just return PLUGIN_HANDLED if !target.

b) In multiple places you use the following:
Code:
get_players(players,num) for(i=0;i<=num;i++) {    // }
Then no where in the loop do you use the players array. If there are 2 people in the server with IDs of 7 and 12, your code starts with 0 and sees if that user is connected, since 0 is not connected it returns PLUGIN_HANDLED and stops. Even if you started at one and 1 happened to be connected, it would only check up to 2 since that is the number of players instead of their IDs.

The proper usage would be:
Code:
get_players(players,num) for(i=0;i<num;i++) {    new player = players[i];    // player is definitely connected, run actions on them as you please }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
pdoubleopdawg
Senior Member
Join Date: Aug 2005
Old 09-09-2005 , 23:08  
Reply With Quote #3

Thanks,
That should help me in the future aswell. I was having the same problem in a few other scripts. Work now.
pdoubleopdawg is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode