AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Stupid question... (https://forums.alliedmods.net/showthread.php?t=10913)

smdobay 03-04-2005 17:55

Stupid question...
 
I'm sure this has been asked before, but I couldn't find it.

I'm making an ns plugin where aliens can (voluntarily) devour each other to gain health. The eating thing works nicely, with one exception.

I need a player to be able to type "devour" into the console, which changes a flag or client side cvar or some other variable to "1", and then the next alien to touch them eats them.

How do I store this value saying "I can be eaten"?

Here's what I have so far:

Code:
public plugin_init() {     register_plugin("amxxNsPlugin","0.5","smdobay")     register_concmd("sacrifice","prep_sacrifice")     register_touch("player", "player", "devour_other")     register_cvar("sv_devour","1",FCVAR_SERVER|FCVAR_SPONLY) } public prep_sacrifice(id){     } public devour_other(id,cid){     if (get_cvar_num("sv_devour") == 1){                 new youName[32]         new otherName[32]                 get_user_name(id,youName,31)         get_user_name(cid,otherName,31)                 new youHealth = get_user_health(id)         new otherHealth = get_user_health(cid)                 if (otherHealth < 0){             otherHealth = 0         }             set_user_health(id,youHealth + otherHealth)                 user_silentkill(cid)                 new msgStr[31]         format(msgStr,30, "You just consumed %s.", otherName)         client_print(id,print_chat,msgStr)         format(msgStr,30, "You were just consumed by %s.", youName)         client_print(cid,print_chat,msgStr)     } }

XxAvalanchexX 03-04-2005 18:17

Code:
new eatable[33]; public plugin_init() {     register_plugin("amxxNsPlugin","0.5","smdobay")     register_concmd("sacrifice","prep_sacrifice")     register_touch("player", "player", "devour_other")     register_cvar("sv_devour","1",FCVAR_SERVER) } public client_putinserver() {     eatable[id] = 0; // make sure to reset it } public prep_sacrifice(id){     if(eatable[id] == 0) {         client_print(id,print_chat,"You can now be eaten by other aliens.");         eatable[id] = 1;     }     else {         client_print(id,print_chat,"You can no longer be eaten by other aliens.");         eatable[id] = 0;     } } public devour_other(id,cid){     if(eatable[cid] == 1) {         set_user_health(id,get_user_health(id) + get_user_health(cid))         client_print(id,print_chat,"You ate another player.")         client_print(cid,print_chat,"You were eaten by another player.")         user_silentkill(cid)     } }

You will also want to check that only aliens can use the sacrifice command and that aliens can't eat marines that had it on.

XxAvalanchexX 03-04-2005 18:18

EDIT: Meant to edit other post, not make a new reply. Delete this please.

smdobay 03-04-2005 18:19

Thanks :D


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

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