AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change sprite when function is called? (https://forums.alliedmods.net/showthread.php?t=11222)

LynX 03-12-2005 17:16

Change sprite when function is called?
 
Mine idea is basically when I call some function I make ( let's say noclip ) - is it possible to change its sprite to another one, but only when one function is called?
So I turn noclip on and one sprite changes to another while noclip is on. And if noclip is off, the sprite changes back to normal. I know its possible, I saw it somewhere on one server...

XxAvalanchexX 03-12-2005 18:14

Yes, it is possible. Are you confusing sprite with model? Do you want to change the player's model while they are noclipped? Where and how do you want the sprite to be displayed?

LynX 03-13-2005 02:37

Nope, I know sprite is not player model, I'm not that much n00b :)
For mod I'm making plugin, it has charging attacks, and different sprite for every attack thats charging.
Mine idea is to replace that sprite by code if I use some action performed on me. So, if charging sprite is, let's say - charge.spr - I would like to change it via code to charge2.spr which is mine sprite and will work only if that function is happening right now. If function is not happening, or stoped, that sprite is returned to normal one.

XxAvalanchexX 03-13-2005 13:58

You would have to find what entity they use to display the charge up sprite, and then find that entity and change whatever keyvalue it is that determines what sprite it displays.

LynX 03-13-2005 14:28

But that sprite is attached to player, not an entity, so I guess no entity finding is necesary? Or if it is, code snippet please... Coz I can't pretty much find it out myself...

Freecode 03-13-2005 14:36

ok u can do it this way

Code:
public changeClip(id) {      new clip = get_user_noclip(id) // Dont noe if this exists      //If it doesnt your next choice is to check his flags see if he has clip or not      if ( clip == 1) // user has noclip      {           set_user_noclip(id,0);           //Change user attached sprite back to normal here      }      else if ( clip == 0 )      {           set_user_noclip(id,1);           //Change user attached sprite to charging      }      return PLUGIN_HANDLED; }

This way all you do is call changeClip(id) and it will automaticly figure out whether to give them clip or to take it away

[EDIT]
This isnt a very best way to do it if ur changing sprite alot. To do it better its best to built another change sprite function where u would specify id and what sprite so u dont have to keep changing sprite in all ur charging functions

LynX 03-13-2005 15:00

Noclip was just example - but the problem is how to actually find out whos using that sprite and then change it? Is something like this possible:
Code:
new sprite[33][33] public checksprite(id) { get_user_info(id,"spritenamehere",sprite[32]) return PLUGIN_HANDLED }

But yet if this above is true, then the main question is - how to replace that sprite?

TotalNoobScripter 03-13-2005 19:26

are u sure the playermodel itself doesnt have the 'sprite' built in? I have a player model that shoots lightning bolts, but the 'charging' effect is actualy built into the model. A plugin i have actually 'shoots' lightning.

Freecode 03-13-2005 21:56

Lynx ur confusing me and urself.
First of tell me how your setting the sprite? Player attachment or as an entity?
In both ways you can just make a bool to identify that the player either has or doesnt have the sprite.
Code:
new bool:hasCharge[32] = false; ...... public changeClip(id) {      new clip = get_user_noclip(id) // Dont noe if this exists      //If it doesnt your next choice is to check his flags see if he has clip or not      if ( clip == 1 && hasCharge[id]) // user has noclip      {           set_user_noclip(id,0);           //Change user attached sprite back to normal here           hasCharge[id] = false; // This user doesnt have charge sprite      }      else if ( clip == 0 && !hasCharge[id])      {           set_user_noclip(id,1);           //Change user attached sprite to charging           hasCharge[id] = true; // This user has charge sprite      }      return PLUGIN_HANDLED; }

LynX 03-14-2005 03:18

Okay, this way - that sprite is a player attachment which follows his right hand and is attached to player as long as I'm holding Mouse1 to charge ( that's an weapon ). I need the code snippet which will replace any sprite under name, let's say, "bigbanga.spr", and replace it with "bigbang2.spr". Only on one player. For others it should remain unchanged. You get me now?


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

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