Raised This Month: $ Target: $400
 0% 

Need Help to change a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mistmoehre
Member
Join Date: Jan 2005
Old 06-02-2006 , 15:47   Need Help to change a plugin
Reply With Quote #1

HI
First: I am a scripting Noob

I found a dawn nice plugin http://forums.alliedmods.net/showthread.php?p=120997
Usage: amx_invis <name|steamid> <on|off> - sets invisibility on or off on user")


But i need a little change...
Usage: amx_invis <name|steamid or @all> <on|off> - sets invisibility on or off on user")


I need it for my Knifeserver (cs 1.6), but with a funktion to give all players the invisible mod. I know this from other amxx plugins..so u can write "amx_funktion @all"

Can anybody help me?


Sry for my bad english, but iŽam German.

PLZ help me

great thanks
Mistmoehre is offline
JohnJ3
Member
Join Date: May 2006
Location: Tomsk
Old 06-02-2006 , 17:33  
Reply With Quote #2

ok, my dear "scripting Noob"
Now, make a reserved copy of file invis.sma
For insert to command a change ("@all") you must insert into script (invis.sma) after string #46 ( read_argv(2,arg2,255);) next strings:
Code:
if (equali(arg1,"@all") && equali(arg2,"on")) {  new num, i  num=get_playersnum(1)  for (i=0; i<num; i++)  {   invisOnOff(i,1,id)  }  return PLUGIN_HANDLED }
for exam, next string must be a new player = cmd_target(id,arg1,2);
...compiling...
change invis.amxx from plugins directory on the invis.amxx from compile directory.
Use command with argument "@all"

I'm not test this plugin in game, but it's compiling (4 warnings - it's few for me ) and this plugin must be work in game. If it false, write here!

Sorry for my bad english, but I'm learn Russian!!!
JohnJ3 is offline
Mistmoehre
Member
Join Date: Jan 2005
Old 06-02-2006 , 18:04  
Reply With Quote #3

Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>

public plugin_init() {
  register_plugin("Invisibilty",AMXX_VERSION_STR,"Disturbed, and Terminal")
  register_concmd("amx_invis","invis",ADMIN_LEVEL_H,"<name|steamid> <on|off> - sets invisibility on or off on user")
}

public invisOnOff(playerID,invisOn,adminID) {
	new name[64];
	get_user_name(playerID,name,63);
	
	if(invisOn==1){
		if(get_entity_visibility(playerID)) {
			console_print(adminID,"Client %s already has invisibility on.",name);
			return PLUGIN_HANDLED
		}
		console_print(adminID,"Invisibility enabled on client %s.",name);
		set_entity_visibility(playerID, 0);
	}  
	if(invisOn==0){
		if(!get_entity_visibility(playerID)) {
		console_print(adminID,"Client %s already has invisibility off.",name);
		return PLUGIN_HANDLED
		}
		console_print(adminID,"Invisibility disabled on client %s.",name);
		set_entity_visibility(playerID, 1);
	}
	return PLUGIN_HANDLED
}

public invis(id,level,cid) {
	if(!cmd_access(id,level,cid,0)) {
		console_print(id,"You do not have access to that command.");
		return PLUGIN_HANDLED
	}
	
	if(access(id,ADMIN_IMMUNITY)&&id!=cid){
		console_print(id,"Client Has Immunity.");
		return PLUGIN_HANDLED
	}
	
	new arg1[256], arg2[256];
	read_argv(1,arg1,255);
	read_argv(2,arg2,255);
	
	if (equali(arg1,"@all") && equali(arg2,"on"))  
	{ 
	 new num, i 
	 num=get_playersnum(1) 
	 for (i=0; i<num; i++) 
	 { 
	  invisOnOff(i,1,id) 
	 } 
	 return PLUGIN_HANDLED 
	}  
	new player = cmd_target(id,arg1,2);
	
	if (equal(arg2,"on")) {
		invisOnOff(player,1,id)
	}
	
	if (equal(arg2,"off")) {
		invisOnOff(player,0,id);
	}
	
	return PLUGIN_HANDLED
}
Is working... compile without warning... but i cant use "amx_invis @all on" :(
A little misstake in your code? =)[/quote]
Mistmoehre is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 06-02-2006 , 18:14  
Reply With Quote #4

Here try this one..
Attached Files
File Type: sma Get Plugin or Get Source (invis.sma - 1019 views - 1.7 KB)
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Mistmoehre
Member
Join Date: Jan 2005
Old 06-02-2006 , 18:26  
Reply With Quote #5

self problem.....

console:
] amx_invis @all on
Unknown command: amx_invis

] amx_invis Mistmoehre on
Invisibility enabled on client sTn | Mistmoehre
Mistmoehre is offline
JohnJ3
Member
Join Date: May 2006
Location: Tomsk
Old 06-02-2006 , 19:00  
Reply With Quote #6

I'm find few mistakes
string with for must be changed to:
Code:
for (i=1; i<=num; i++)
but not for (i=0; i<num....)!
because first playerid=1 and last playerid=num...
now my plugin work in a game! try again use amx_invis @all on
it's very strange that he say "unknown command"...
JohnJ3 is offline
Mistmoehre
Member
Join Date: Jan 2005
Old 06-02-2006 , 19:15  
Reply With Quote #7

Great Thanks
but i have testet with 8 players on my server and it dosent work correkt...

console:
] amx_invis @all on
Invisibility enabled on client $VanO

Now "$VanO" is invisible but only this player and no other
Mistmoehre is offline
Mistmoehre
Member
Join Date: Jan 2005
Old 06-02-2006 , 21:16  
Reply With Quote #8

ok P34nut post me the right code

Code:
#include <amxmodx> 
#include <amxmisc> 
#include <engine> 

public plugin_init() { 
  register_plugin("Invisibilty",AMXX_VERSION_STR,"Disturbed, and Terminal") 
  register_concmd("amx_invis","invis",ADMIN_LEVEL_C,"<name|steamid|@all> <on|off> - sets invisibility on or off on user") 
} 

public invisOnOff(playerID,invisOn,adminID) { 
    new name[64]; 
    get_user_name(playerID,name,63); 
     
    if(invisOn==1){ 
        if(get_entity_visibility(playerID)) { 
            console_print(adminID,"Client %s already has invisibility on.",name); 
            return PLUGIN_HANDLED 
        } 
        console_print(adminID,"Invisibility enabled on client %s.",name); 
        set_entity_visibility(playerID, 0); 
    }   
    if(invisOn==0){ 
        if(!get_entity_visibility(playerID)) { 
        console_print(adminID,"Client %s already has invisibility off.",name); 
        return PLUGIN_HANDLED 
        } 
        console_print(adminID,"Invisibility disabled on client %s.",name); 
        set_entity_visibility(playerID, 1); 
    } 
    return PLUGIN_HANDLED 
} 

public invis(id,level,cid) { 
    if(!cmd_access(id,level,cid,0)) { 
        console_print(id,"You do not have access to that command."); 
        return PLUGIN_HANDLED 
    } 
     
    if(access(id,ADMIN_IMMUNITY)&&id!=cid){ 
        console_print(id,"Client Has Immunity."); 
        return PLUGIN_HANDLED 
    } 
     
    new arg1[256], arg2[256]; 
    read_argv(1,arg1,255); 
    read_argv(2,arg2,255); 
     
    if(equali(arg1, "@all")) { 
        new num, Players[32] 
        get_players(Players, num, "h") 
         
        for(new i = 0; i < num; i++) { 
            if(is_user_connected(i) && is_user_alive(i)) { 
                if (equal(arg2,"on")) { 
                    invisOnOff(i,1,id) 
                } 
                 
                if (equal(arg2,"off")) { 
                    invisOnOff(i,0,id); 
                } 
            } 
        } 
    } else { 
        new player = cmd_target(id,arg1,2); 
         
        if (equal(arg2,"on")) { 
            invisOnOff(player,1,id) 
        } 
         
        if (equal(arg2,"off")) { 
            invisOnOff(player,0,id); 
        } 
    } 
     
    return PLUGIN_HANDLED 
}
Thanks to P34nut and all other they try to help me =)
Mistmoehre is offline
JohnJ3
Member
Join Date: May 2006
Location: Tomsk
Old 06-02-2006 , 23:24  
Reply With Quote #9

ok, but why "for (i=0; i<num; i++)" ?
JohnJ3 is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 06-02-2006 , 23:40  
Reply With Quote #10

Because...

To begin wtih i is set to 0, but as long as i is less than num, it keeps adding one with i++
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
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 16:30.


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