AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unsure of how (https://forums.alliedmods.net/showthread.php?t=28936)

NewUser 05-25-2006 23:44

Unsure of how
 
Is this right? Basicly what I'm trying to do is that the victim can affect the killer somehow, menu wise.

Code:
public DeathMSG() {     new killer = read_data(1);     new victim = read_data(2);     new iMenu[256];     new key = (1<<0|1<<1)     format(iMenu,sizeof(iMenu), "Neo...^n");     add(iMenu,sizeof(iMenu), "^n1. The matrix");     add(iMenu,sizeof(iMenu), "^n2. Has you.");     show_menu(victim, key, iMenu); } public wtfness(victim, killer, key) {     // when they press the button and stuff code. }

Xanimos 05-26-2006 00:01

Is that your whole plugin? Paste all the code.

NewUser 05-26-2006 00:56

Quote:

Originally Posted by Suicid3
Is that your whole plugin? Paste all the code.

I was just writing a draft. I wasn't going to get started on the actual plugin until I was sure.

Pablo 05-26-2006 01:51

go here -> http://wiki.amxmodx.org/index.php/Ad...28AMX_Mod_X%29

look about a third of the way down the page for these two code sample blocks... they *may* be germaine to what you are coding:
(I'm thinking you want hook_death...)

Quote:

Code:

public plugin_init()
{
    register_plugin("Message Demo", "1.0", "BAILOPAN")
    //this message informs everyone of a death, so we use
    // flag "a" - global event
    register_event("DeathMsg", "hook_death", "a")
}
 
public hook_death()
{
    new Killer = read_data(1) //get the first message parameter
    new Victim = read_data(2) //get the second message parameter
    new headshot = read_data(3) //was this a headshot?
    new weapon[32]
    read_data(4, weapon, 31)  //get the weapon name
}

Or, let's say we want to make a simple function for generating a death message:

Code:

stock make_deathMsg(Killer, Victim, const weapon[])
{
    //message_begin starts a message.  NEVER start two messages at once.
    //MSG_ALL means send the message to everyone
    //get_user_msgid returns the id of a message name
    //{0,0,0} is the origin vector - not used here
    //0 is the target - no specific target here
    message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
    write_byte(Killer)
    write_byte(Victim)
    write_string(weapon)
    message_end()
}



NewUser 05-26-2006 13:46

Not exactly.

Maybe this will help y'all understand a little better.

Code:
new iCash[33]; #define cash_low #define cash_medium #define cash_last // ... public DeathMSG() {     new killer = read_data(1)     new victim = read_data(2)     new iMenu[256];     new key = (1<<0|1<<1)     format(iMenu,sizeof(iMenu), "Neo...^n");     add(iMenu,sizeof(iMenu),"^n1. The matrix");     add(iMenu,sizeof(iMenu),"^n2. Has you...");     show_menu(victim, key, iMenu); } public iMenu_exec(victim, killer, key) {     if(key == 0)     {         if(iCash[killer] == cash_low)         {             iCash[killer] = cash_medium             return PLUGIN_HANDLED;         if(iCash[killer] == cash_medium)         {             iCash[killer] = cash_last             return PLUGIN_HANDLED;         if(iCash[killer] == cash_last)         {             // my stuff             return PLUGIN_HANDLED;         }         iCash[killer] = cash_low         return PLUGIN_HANDLED;     }     else if(key == 1)     {         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }

Zenith77 05-26-2006 15:10

What you have can work, you just need a global var to store who killed who...

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> enum CashLevel {      CASH_LOW = 0,      CASH_MEDIUM,      CASH_HIGH }; new myKiller[33]; new CashLevel:cashLevel[33]; // ... //Just a func to label their cash //Will set a users cash level and return it. CashLevel:SetCashLevel(id) {          if(cs_get_user_money < 2000) {                 cashLevel[id] = CASH_LOW;                 return CASH_LOW;          }                        //....          return CASH_LOW; // We really should never reach here... } public DeathMSG() {     new killer = read_data(1)     new victim = read_data(2)                 myKiller[victim] = killer;     // Why are you prefixing this with i, it's a string, not an array of ints!                 new iMenu[256];     new key = (1<<0|1<<1)     format(iMenu,sizeof(iMenu), "Neo...^n");     add(iMenu,sizeof(iMenu),"^n1. The matrix");     add(iMenu,sizeof(iMenu),"^n2. Has you...");     show_menu(victim, key, iMenu); } public iMenu_exec(id, key) {                      SetCashLevel(myKiller[id]);                            switch(key) {                      //Key number 1 pressed          case 0: {                            if(cashLevel[myKiller[id]] == CASH_LOW)                                  // Do something here                       }                        //Key number 2                        case 1: // ...                  }     return PLUGIN_HANDLED; }

*Ok, something is wrong with the small tags, code came out poorly formatted

This what I think you were trying to do. Also, I typed the code up in the post a reply section, so there is most likely errors, it's just a snippet anyway. Let me know if you need any help understanding the script.


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

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