AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   variable in hudmessage? (https://forums.alliedmods.net/showthread.php?t=11837)

Belsebub 03-29-2005 16:38

variable in hudmessage?
 
how to show a variable in a hudmessage?

i know how to show hp and stuff but not variables

hp example:
Code:
 public hpmessage(id)  {     new health[33]     get_user_health(id,health,32)     set_hudmessage(200, 200, 0, -1.0, 0.45, 2, 6.0, 3.0, 0.01, 0.1, 86)     show_hudmessage(id, "You have %i HP", health)     return PLUGIN_HANDLED  }

variabel?:
Code:
 public message(id)  {     new something[33]     ?????(id,something,32)     set_hudmessage(200, 200, 0, -1.0, 0.45, 2, 6.0, 3.0, 0.01, 0.1, 86)     show_hudmessage(id, "You have %i something", something)     return PLUGIN_HANDLED  }

FeuerSturm 03-29-2005 17:19

i'm not sure what you actually want, give an example for what
you want to display and i'm sure i can help you.

twistedeuphoria 03-29-2005 18:40

%d for integers
%f for floats
%s for strings

Is that what you wanted?

XxAvalanchexX 03-29-2005 18:42

%i for integers, actually
%d stands for data... not sure quite exactly what it was meant for, but it can be used for integers.

twistedeuphoria 03-29-2005 18:49

Oh really, you learn something new every day, or week, or w/e. %d always worked for me :)

Twilight Suzuka 03-29-2005 18:53

%d can be used in place of %i, %f, and %s. it figures out what your trying to display and displays it. There is some sort of downside, but I forget what it is.

Belsebub 03-30-2005 04:45

example: so if i want to show the variable something in the hudmessage i do like this?

Code:
new something = 1 public message(id) {     set_hudmessage(200, 200, 0, -1.0, 0.45, 2, 6.0, 3.0, 0.01, 0.1, 86)     show_hudmessage(id, "something is %d", something)     return PLUGIN_HANDLED }

Belsebub 03-30-2005 05:08

and i also saw this in another topic and i cant get it to work so can anyone explain how to use it or give me a code example?

Code:
new Float:maxspeed = 319.0 + float(level); set_user_maxspeed(id,maxspeed);

Johnny got his gun 03-30-2005 07:11

http://www.cppreference.com/stdio/printf.html

Belsebub 03-30-2005 08:18

ok i need some help, i am working on a stats plugin that allows you to choose 5 stats, i have only done the constitution stat now, but i need someone to fix the code cause i get theese errors when i compile:

Code:

(8) : error 017: undefined symbol "constitution"
(8 -- 9) : error 008: must be a constant expression; assumed zero

the plugin:

Code:
 //----------------------------------------------------------------------------------------------  #include <amxmodx>  #include <amxmisc>  #include <engine>  #include <fun>  //----------------------------------------------------------------------------------------------  // VARIABLES  new hp[33] = 10 * (constitution[id])  new constitution[33] = 0 new pointsleft[33] = 5  //----------------------------------------------------------------------------------------------  public plugin_init()  {     register_plugin("Stats", "1.0", "Belsebub")     register_menucmd(register_menuid("Stats Menu"), 1023, "ActionMenu")     register_event("ResetHUD", "Event_Resethud", "a")  }  //----------------------------------------------------------------------------------------------  ShowMenu(id)  {     new szMenuBody[256]     new keys     new len = format( szMenuBody, 255, "Stats Menu:^n" )     len += format( szMenuBody[len], 255-len, "^n\w1. Constitution" )     len += format( szMenuBody[len], 255-len, "^n\w2. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w3. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w4. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w0. Exit )     keys = (1<<0|1<<1|1<<2|1<<3|1<<9)     show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public ActionMenu(id, key)  {     switch(key)     {         case 0:         {             constitution[id] += 1             pointsleft[id] -= 1         }         case 1:         {         }         case 2:         {         }         case 3:         {         }         case 4:         {         }     }  }  //----------------------------------------------------------------------------------------------  public Event_Resethud(id)  {     new health = get_user_health ( id )     set_user_health(id, health + hp[id])  }  //----------------------------------------------------------------------------------------------

and i also want to show the current constitution the player has in the menu after the option Constitution, like this if the person has 5 constitution the option will be :

Constitution (5)


All times are GMT -4. The time now is 09:52.

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