AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need Help to change a plugin (https://forums.alliedmods.net/showthread.php?t=29289)

Mistmoehre 06-02-2006 15:47

Need Help to change a plugin
 
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

JohnJ3 06-02-2006 17:33

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!!! 8)

Mistmoehre 06-02-2006 18:04

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]

SweatyBanana 06-02-2006 18:14

1 Attachment(s)
Here try this one..

Mistmoehre 06-02-2006 18:26

self problem.....

console:
] amx_invis @all on
Unknown command: amx_invis

] amx_invis Mistmoehre on
Invisibility enabled on client sTn | Mistmoehre

JohnJ3 06-02-2006 19:00

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

Mistmoehre 06-02-2006 19:15

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 06-02-2006 21:16

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 =)

JohnJ3 06-02-2006 23:24

ok, but why "for (i=0; i<num; i++)" ?

SweatyBanana 06-02-2006 23:40

Because...

To begin wtih i is set to 0, but as long as i is less than num, it keeps adding one with i++


All times are GMT -4. The time now is 16:30.

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