AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   possible to do these? (https://forums.alliedmods.net/showthread.php?t=64297)

Checkmarks 12-12-2007 14:53

possible to do these?
 
(1) Is there a way to make it so that people cannot buy items in the game? I'm currently making a plugin for CS1.6 and I want it so that nobody can buy anything. Like, perhaps restrict all weapons in an easy way, get rid of buyzones, etc. What would be the most effective way, and how do I do it?

(2) How can I make it so that players CANNOT pickup any guns from the ground.


Thanks in advance.
Oh and also I know this is an easy question, but how to make somebody become partially invisible, I guess about as much invisibility as in the wc3 mod when you have lvl3 invisibility and holding a knife? Pretty invisible :D

PSS: Last thing ;) I need to know how to increase somebody's damage that they do with certain guns. Thanks :D

~Chex

purple_pixie 12-12-2007 15:18

Re: possible to do these?
 
Right.

1) Remove buyzones is my suggestion.
What you need to do is to loop through each entity that is a "func_buyzone" and kill it.

Code:
    new ent ;     // create our "entity" variable.     // this will hold the currently looked at entity     while ( ( ent = ( engfunc(EngFunc_FindEntityByString,ent,"classname","func_buyzone")) ) )     //keep setting ent to the next entity that is called func_buyzone, for as long as there are more     {         engfunc(EngFunc_RemoveEntity,ent) ;         // and kill this entity     }
Call that on map start, so plugin_init or w/e.
(I think ... don't trust that last statement)

2) Register the "touch" event between the player and the gun, and return FMRES_SUPERCEDE to block it:

Code:
public plugin_init()    {     // during our initialisation function     register_forward(FM_Touch,"on_touch",0)     // register the "touch" event to a function (that we wrote) called on_touch     // whenever two bodies touch, this function will be called } public on_touch(id,ent) {   if ( !is_user_connected(id) || !pev_valid(ent))     // if "id" is not a player, or "ent" is not an entity (object) quit         return FMRES_IGNORED ;         static classname[32] ;     // create a classname variable     // "static" means use the same variable every time the function is called     pev(ent,pev_classname,classname,sizeof classname - 1 )     // get ent's classname     if ( ( ! equal(classname,"weapon",6) ) && ( !equal(classname,"armoury",7) ) )     // if it doesn't start "weapon" or "armoury", we don't care         return FMRES_IGNORED ;         return FMRES_SUPERCEDE ;     // this means "block the event" }

To make someone invisible, you need to set their rendering, and specify the "alpha" as anything < 255.
Code:
set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, ALPHA [e.g. 30])

If you need any comments explaining any of the code just ask.
If I don't pick it up, someone else should.

Checkmarks 12-12-2007 15:27

Re: possible to do these?
 
Thanks a million. So I'm guessing 255 is purely visible? So would 30 be good for still visible, but easy to pass up?

PS: New Question:
- I am using "set_user_maxspeed(id, get_user_maxspeed(id) * 3);" to make somebody's speed 3 times the normal speed. While searching the set_user_maxspeed and get_user_maxspeed functions, I noticed somebody post about how you had to "Hook the CurWeapon" function or something so that every time you change weapons, the speed wouldn't get reset back to normal.
Do you know anything about this>?

oh and, I still need to know how to increase somebody's damage that they do with certain guns

- Thanks

purple_pixie 12-12-2007 15:46

Re: possible to do these?
 
255 is 100% visible.
0 is 100% INVisible

30 is pretty damned invisible.
Still visible, though.

Ah yes, I forgot the extra damage.
More on that later

"CurWeapon" is a message, sent when you do just about anything with a Weapon.
user_maxspeed is reset (by CS) whenever you change weapon.

So to triple it, you need to do so only when they change weapon, and when they spawn.

This would be how you hook CurWeapon:
Code:
new user_weapon[33] ; public plugin_init()     register_event("CurWeapon","on_curweapon","be") public on_curweapon(id) {     static tempweapon ;     tempweapon = get_user_weapon(id,tempweapon,tempweapon) ;     if ( tempweapon == user_weapon[id] )         return PLUGIN_CONTINUE ;     user_weapon[id] = tempweapon     set_user_maxspeed(id,get_user_maxspeed(id)*3) ;     return PLUGIN_CONTINUE ; }
You see that we keep the player's current weapon in an array, and when it changes we change his speed.

Damage with a weapon I'm not certain about ... you *should* be able to do it with HamSandwich module, but it doesn't work for me.
(The "Inflictor" [weapon] argument is always the player and not the weapon)

The advantage to doing it with HS is that you can catch the damage before it damages the player, and adjust the damage it deals.
And then let CS do the damaging itself.

What I suggest is looking at the WC3 source, or similar.
Try looking at other plugins that do similar things.

EDIT: I have no idea why I'm being so helpful. Could be because I'm in such a good mood.
Aren't you lucky?

Checkmarks 12-12-2007 16:05

Re: possible to do these?
 
thanks, ill read some wc3 source later.

ok my code is coming along great because of your help, you'll definately be in the credits ;)

maybe you could keep up the good mood? I always have more questions! :D

1) How to strip weapons (All except knife ; or just strip all then give knife) on every new round? Kinda like on scoutzknivez you know how they strip everything then give you knife+scout ;)

2) with all these new things you're giving me, do i need to include any new modules besides fun and amxmodx?

3) the big question... Okay so basically here's PART of my code..
Code:

register_clcmd( "/class","classmenu")
and then it shows the menu I made.. The thing is, I ALSO want to make the menu appear automatically when somebody joins, like in wc3. Ofcourse if you don't know I could always look in the wc3 source while searching the damage thing.

Thanks in advance! I will have more questions, aren't you excited? :D

ConnorMcLeod 12-12-2007 16:21

Re: possible to do these?
 
Quote:

Originally Posted by purple_pixie (Post 562721)
Code:
new user_weapon[33] ; public plugin_init()     register_event("CurWeapon","on_curweapon","be") public on_curweapon(id) {     static tempweapon ;     tempweapon = get_user_weapon(id,tempweapon,tempweapon) ;     if ( tempweapon == user_weapon[id] )         return PLUGIN_CONTINUE ;     user_weapon[id] = tempweapon     set_user_maxspeed(id,get_user_maxspeed(id)*3) ;     return PLUGIN_CONTINUE ; }

Why retreive weapon with get_user_weapon when read_data(2) does it ?

Checkmarks 12-12-2007 16:27

Re: possible to do these?
 
Are you saying i need to change something when i put that into my code? or will it still work?

and PS: I know the code "strip_user_weapons(id)" but how can I do this every time round starts? I'm making a menu and one of the classes available to choose is where you get ONLY an awp. so i want to make sure it strips all weapons every round start (i know how to give the awp)

thanks

purple_pixie 12-12-2007 16:59

Re: possible to do these?
 
Quote:

Originally Posted by connorr (Post 562735)
Why retreive weapon with get_user_weapon when read_data(2) does it ?

Because there's still an awful lot about this I don't know.

Thanks.

Code:
new user_weapon[33] ; public plugin_init()     register_event("CurWeapon","on_curweapon","be") public on_curweapon(id) {     static tempweapon ;     tempweapon = read_data(2) ;     if ( tempweapon == user_weapon[id] )         return PLUGIN_CONTINUE ;     user_weapon[id] = tempweapon     set_user_maxspeed(id,get_user_maxspeed(id)*3) ;     return PLUGIN_CONTINUE ; }

For stripping weapons, you want the spawn event.
But not right on the spawn, set a task for it.

Code:
#define MAX_PLAYERS 32 enum ( += MAX_PLAYERS ) {     TASK_SPAWN } public plugin_init()     register_forward(FM_Spawn,"on_spawn",1) public on_spawn(id) {     if ( task_exists(TASK_SPAWN+id) )         remove_task(TASK_SPAWN+id) ;     set_task(0.5,"on_timedspawn",TASK_SPAWN+id) } public on_timedspawn(id) {     if ( id > TASK_SPAWN )         id -= TASK_SPAWN ;     if ( is_user_connected(id) )         strip_user_weapons(id) ;    }

Checkmarks 12-12-2007 17:08

Re: possible to do these?
 
Okay I understand the code but I'm confused about something.
Here's my plugin so far:
Code:

#include <amxmodx>
#include <fun>

new ninjahp
new grenaderhp
new bondhp
new rambohp
new robothp
new sniperhp
new zombiehp

new user_weapon[33] ;

public plugin_init()
{

  register_event("CurWeapon","on_curweapon","be")
 
  register_plugin("SNAM","1.0","Checkmarks")
  register_clcmd( "/class","classmenu")
 
  ninjahp = register_cvar("ninja_hp","250")
  grenaderhp = register_cvar("grenader_hp","150")
  bondhp = register_cvar("bond_hp","100")
  rambohp = register_cvar("rambo_hp","130")
  robothp = register_cvar("robot_hp","300")
  sniperhp = register_cvar("sniper_hp","100")
  zombiehp = register_cvar("zombie_hp","500")
     
      new ent ;
    while ( ( ent = ( engfunc(EngFunc_FindEntityByString,"classname","func_buyzone")) ) )
    {
        engfunc(EngFunc_RemoveEntity,ent) ;
    }
   
    register_forward(FM_Touch,"on_touch",0)
    on_touch(id,ent)
  { 
      if ( !is_user_connected(id) || !pev_valid(ent))
      return FMRES_IGNORED ;
      static classname[32] ;
      pev(ent,pev_classname,classname,sizeof classname - 1 )
      if ( ( ! equal(classname,"weapon",6) ) && ( !equal(classname,"armoury",7) ) )
      return FMRES_IGNORED ;
      return FMRES_SUPERCEDE ;
  }
}

  public classmenu(id)
{
      new menu = menu_create("\rPick a Class:", "menu_handler")
      menu_additem(menu, "\wBond", "1", 0)
      menu_additem(menu, "\wGrenader", "2", 0)
      menu_additem(menu, "\wNinja", "3", 0)
      menu_additem(menu, "\wRambo", "4", 0)
      menu_additem(menu, "\wRobot", "5", 0)
      menu_additem(menu, "\wSniper", "6", 0)
      menu_additem(menu, "\wZombie", "7", 0)
      menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
      menu_display(id, menu, 0)
}
  public menu_handler(id, menu, item)
{
      if (item == MENU_EXIT)
        {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
   
      new data[6], iName[64]
      new access, callback
      menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
      new key = str_to_num(data)
      switch(key)
        {
        case 1:
          {
              set_user_health(id,get_pcvar_num(bondhp))
          set_user_maxspeed(id, get_user_maxspeed(id) * 2);
          give_item(id, "weapon_deagle")
          give_item(id, "weapon_ak47")
          }
        case 2:
          {
              set_user_health(id,get_pcvar_num(grenaderhp))
          set_user_gravity(id, 0.75);
          set_user_maxspeed(id, get_user_maxspeed(id) * 2);
          give_item(id, "weapon_mp5navy")
          give_item(id, "weapon_usp")
          give_item(id, "weapon_hegrenade")
          give_item(id, "weapon_flashbang")
          give_item(id, "weapon_smokegrenade")
          }
        case 3:
          {
              set_user_maxspeed(id, get_user_maxspeed(id) * 2);
              set_user_gravity(id, 0.25);
              set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, 30)
          set_user_health(id,get_pcvar_num(ninjahp))
          give_item(id, "weapon_knife")
          give_item(id, "weapon_flashbang")
          }
        case 4:
          {
              set_user_health(id,get_pcvar_num(rambohp))
          set_user_maxspeed(id, get_user_maxspeed(id) * 2);
          give_item(id, "weapon_m249")
          give_item(id, "weapon_elites")
          give_item(id, "weapon_hegrenade")
          give_item(id, "item_assaultsuit")
          }
        case 5:
          {
              set_user_health(id,get_pcvar_num(robothp))
          give_item(id, "weapon_m3")
          give_item(id, "weapon_tmp")
          give_item(id, "weapon_fiveseven")
          give_item(id, "weapon_deagle")
          }
        case 6:
          {
              give_item(id, "weapon_awp")
          give_item(id, "weapon_scout")
          give_item(id, "weapon_flashbang")
          give_item(id, "weapon_smokegrenade")
          give_item(id, "weapon_g3sg1")
          get_user_health(id,get_pcvar_num(sniperhp))
          }
        case 7:
          {
              set_user_maxspeed(id, get_user_maxspeed(id) * 3);
              set_user_gravity(id, 0.50);
              set_user_health(id,get_pcvar_num(zombiehp))
          give_item(id, "weapon_knife")
          }
    }
    menu_destroy(menu)
        return PLUGIN_HANDLED
}

public on_curweapon(id)
{
    static tempweapon ;
    tempweapon = read_data(2) ;
    if ( tempweapon == user_weapon[id] )
        return PLUGIN_CONTINUE ;
    user_weapon[id] = tempweapon
    set_user_maxspeed(id,get_user_maxspeed(id)*3) ;
    return PLUGIN_CONTINUE ;
}

I'm a bit confused.
What I'm trying to do is strip everybody's weapons at the beginning of the round. Then, I want to give specific weapons to each specific class (a class is like sniper etc. that people choose when joining). So for example, if somebody was a Ninja, how could I strip all their weapons and THEN give them a knife every time a round starts?
You may have already told me, but I'm really really new ;)
If you could help that'd be great, like maybe edit it into my code?

-thanks
ps: as you can see i already have what guns i want every class to have being given to them, but i want this done every time a new round starts, and AFTER the strip weapons feature..

-thanks again

purple_pixie 12-13-2007 04:41

Re: possible to do these?
 
What you should do, is to have an array of player classes.

Then when they do the class menu, change that player's entry in the array.

Then on spawn, check their class from the array and do the give_item there.

EDIT: And a couple other things ...

You "on_touch" event is inside plugin_init, it seems.
And it should be "public on_touch" since it is called by CS, and not your plugin.

I know I posted "on_touch" but I forgot to make it public.


EDIT: And I probably shouldn't just give you exact code, let alone edit yours.
If you get too much help too early on you'll never be able to help yourself.


All times are GMT -4. The time now is 11:12.

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