AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to get back the unknown string of two public ? (https://forums.alliedmods.net/showthread.php?t=56952)

lucky109 06-25-2007 00:51

how to get back the unknown string of two public ?
 
Code:

#include <amxmodx>

#define PLUGIN "G-HK Private Messaging"
#define VERSION "1.0"
#define AUTHOR "Yin"

public plugin_init() {
        register_clcmd( "test","testmenu", -1, "test menu" )
        register_menucmd(register_menuid("\yTest Menu:"), 1023, "MenuCommand" )
}

public testmenu(id)
{
  new szMenuBody[256]
  new keys

  new nLen = format( szMenuBody, 255, "\yTest Menu:^n" )
  nLen += format( szMenuBody[nLen], 255-nLen, "^n\r1. %d",random(256))
  nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w2. Exit" )

  keys = (1<<0|1<<1)

  show_menu( id, keys, szMenuBody, -1 )
  return PLUGIN_CONTINUE
}

public MenuCommand( id, key )
{
  switch( key )
  {
      case 0: how can i get back the %d numbers?
      case 1: client_print(id, print_chat, "exit test menu.")
  }
  return PLUGIN_HANDLED
}


Sylwester 06-25-2007 04:35

Re: how to get back the unknown string of two public ?
 
PHP Code:

#include <amxmodx>

#define PLUGIN "G-HK Private Messaging"
#define VERSION "1.0"
#define AUTHOR "Yin"

new g_number[33]

public 
plugin_init() {
    
register_clcmd"test","testmenu", -1"test menu" )
    
register_menucmd(register_menuid("\yTest Menu:"), 1023"MenuCommand" )
}

public 
testmenu(id)
{
   new 
szMenuBody[256]
   new 
keys

   g_number
[id] =  random(256)

   new 
nLen formatszMenuBody255"\yTest Menu:^n" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\r1. %d",g_number[id])
   
nLen += formatszMenuBody[nLen], 255-nLen"^n^n\w2. Exit" )

   
keys = (1<<0|1<<1)

   
show_menuidkeysszMenuBody, -)
   return 
PLUGIN_CONTINUE
}

public 
MenuCommandidkey )
{
   switch( 
key )
   {
       case 
0//g_number[id]
       
case 1client_print(idprint_chat"exit test menu.")
   } 
   return 
PLUGIN_HANDLED



lucky109 06-25-2007 08:04

Re: how to get back the unknown string of two public ?
 
PHP Code:

#include <amxmodx>

#define PLUGIN "G-HK Private Messaging"
#define VERSION "1.0"
#define AUTHOR "Yin"

new g_number[33]

public 
plugin_init() {
    
register_clcmd"test","testmenu", -1"test menu" )
    
register_menucmd(register_menuid("\yTest Menu:"), 1023"MenuCommand" )
}

public 
testmenu(id)
{
   new 
szMenuBody[256]
   new 
keys

   g_number
[id] =  random(256)

   new 
nLen formatszMenuBody255"\yTest Menu:^n" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\r1. %d",g_number[id])
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\r2. %d",g_number[id])
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\r3. %d",g_number[id])
   
nLen += formatszMenuBody[nLen], 255-nLen"^n^n\w2. Exit" )

   
keys = (1<<0|1<<1)

   
show_menuidkeysszMenuBody, -)
   return 
PLUGIN_CONTINUE
}

public 
MenuCommandidkey )
{
   switch( 
key )
   {
       case 
0: ??
       case 
1: ??
       case 
2: ??
       case 
3client_print(idprint_chat"exit test menu.")
   } 
   return 
PLUGIN_HANDLED


how can i get the numbers if player choose one case and if three string using g_number?

Alka 06-25-2007 08:29

Re: how to get back the unknown string of two public ?
 
Something is rong in menu when i press 3 is not working but w/e (I don't like "old style menu") ! This works

Code:

#include <amxmodx>
 
#define PLUGIN "G-HK Private Messaging"
#define VERSION "1.0"
#define AUTHOR "Yin"
 
new g_number[33][3]
 
public plugin_init() {
 register_clcmd( "test","testmenu", -1, "test menu" )
 register_menucmd(register_menuid("\yTest Menu:"), 1023, "MenuCommand" )
}
 
public testmenu(id)
{
 new szMenuBody[256]
 new keys
 
 g_number[id][0] =  random(256)
 g_number[id][1] =  random(256)
 g_number[id][2] =  random(256)
 
 new nLen = format( szMenuBody, 255, "\yTest Menu:^n" )
 nLen += format( szMenuBody[nLen], 255-nLen, "^n\r1. %d",g_number[id][0])
 nLen += format( szMenuBody[nLen], 255-nLen, "^n\r2. %d",g_number[id][1])
 nLen += format( szMenuBody[nLen], 255-nLen, "^n\r3. %d",g_number[id][2])
 nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w2. Exit" )
 
 keys = (1<<0|1<<1)
 
 show_menu( id, keys, szMenuBody, -1 )
 return PLUGIN_CONTINUE
}
 
public MenuCommand( id, key )
{
 switch( key )
 {
  case 0: client_print(id,print_chat,"Number: %d",g_number[id][0]) // This is the result number i you press 1.
 
  case 1: client_print(id,print_chat,"Number: %d",g_number[id][1]) // _,,_ if you press 2.
 
  case 2: client_print(id,print_chat,"Number: %d",g_number[id][2]) // _,,_ if you press 3.
 
  case 3: client_print(id, print_chat, "exit test menu.")
 
 } 
 return PLUGIN_HANDLED
}

:wink:

lucky109 06-25-2007 09:31

Re: how to get back the unknown string of two public ?
 
can i make it's %d if i have unknown number string ?

g_number[id][%d] = random(256)

Alka 06-25-2007 09:58

Re: how to get back the unknown string of two public ?
 
Dunno what you'r tryng to do , or what you talking about!

Quote:

Originally Posted by lucky109
can i make it's %d if i have unknown number string ?

why?If you want to have more put any number to 99! This "%d" (integer) is to show the number!

lucky109 06-25-2007 10:22

Re: how to get back the unknown string of two public ?
 
Quote:

Originally Posted by Alka (Post 494481)
Dunno what you'r tryng to do , or what you talking about!

why?If you want to have more put any number to 99! This "%d" (integer) is to show the number!

i'm making something with mysql...
i have two table in mysql (db = test):

number | name
 5    Sam
 45    Paul
 67   Sam

Code:

public plugin_init() {
        register_clcmd("test","ShowMenu", -1, "show est menu")
        register_menucmd(register_menuid("\yTest Menu"), 1023, "MenuCommand")


public ShowMenu(id)
{
  new CSName[32];
  get_user_name(id, CSName, 31);
  result = dbi_query(dbc,"SELECT * FROM `test` WHERE `name` = '%s'", CSName)

  new szMenuBody[256]
  new keys

  new nLen = format( szMenuBody, 255, "\wTest Menu:^n" )

  new number[64];
  for (new i=1;i<=dbi_num_rows(result);i++)
  {
  dbi_nextrow(result)
  dbi_result(result,"number",number,63)
  nLen += format( szMenuBody[nLen], 255-nLen, "^n\w%d. %s",i,number)
  }

  keys = (1<<0|1<<1)

  show_menu( id, keys, szMenuBody, -1 )
  return PLUGIN_CONTINUE
}

public MenuCommand( id, key )
{
  switch( key )
  {
      case 0: how can i get the result number if the player choose case0?
      case 1: how can i get the result inumber f the player choose case1?
  }
  return PLUGIN_HANDLED
}

example:
one player connect server , he's name called "Sam"
type "test" in console...it's show menu like:

1. 5
2. 67

if he press 1 , case 0 i want to get the number 5
if he press 2 , case 1 i want to get the number 67

sorry...my bad english....thanks

Alka 06-25-2007 10:54

Re: how to get back the unknown string of two public ?
 
Man look carefully at my code above again! When display menu is showing random numbers for option 1. 2. 3. !

After that at function under menu display you showing the results!

g_number[id][0]
g_number[id][1] // Those are results!
g_number[id][2]

lucky109 06-25-2007 11:08

Re: how to get back the unknown string of two public ?
 
Quote:

Originally Posted by Alka (Post 494505)
Man look carefully at my code above again! When display menu is showing random numbers for option 1. 2. 3. !

After that at function under menu display you showing the results!

g_number[id][0]
g_number[id][1] // Those are results!
g_number[id][2]

Code:

public plugin_init() {
        register_clcmd("test","ShowMenu", -1, "show est menu")
        register_menucmd(register_menuid("\yTest Menu"), 1023, "MenuCommand")


public ShowMenu(id)
{
  new CSName[32];
  get_user_name(id, CSName, 31);
  result = dbi_query(dbc,"SELECT * FROM `test` WHERE `name` = '%s'", CSName)

  new szMenuBody[256]
  new keys

  new nLen = format( szMenuBody, 255, "\wTest Menu:^n" )

  new number[64];
  for (new i=1;i<=dbi_num_rows(result);i++)
  {
  g_number[id][0] =  ("%d", number) // here save one result to [0]
  //then how to save the result to [1] [2] [3]....?? (may added new date anytime)
  dbi_nextrow(result)
  dbi_result(result,"number",number,63)
  nLen += format( szMenuBody[nLen], 255-nLen, "^n\w%d. %s",i,number)
  }

  keys = (1<<0|1<<1)

  show_menu( id, keys, szMenuBody, -1 )
  return PLUGIN_CONTINUE
}

public MenuCommand( id, key )
{
  switch( key )
  {
      case 0: client_print(id, print_chat, "The result number is %d",g_number[id][0])
      case 1: client_print(id, print_chat, "The result number is %d",g_number[id][1])
  }
  return PLUGIN_HANDLED
}

fine..
there have two result in this case..

how can i use "for (new i=1;i<=dbi_num_rows(result);i++)" to make [0] = i++ to save the value??

g_number[id][0] = ("%d", number)

Alka 06-25-2007 11:22

Re: how to get back the unknown string of two public ?
 
Man you don't understand something! g_number[id][0] saves the number already! You must use it somewhere ;like in print_chat!

Code:

g_number      [id]            [3]
array          player id  maxim values

so if you want to have more values add [10] so you will have
g_number[id][0]
g_number[id][1] //2D arrays
g_number[id][2]
....................
g_number[id][9] :|

Or you can do like this:
Code:

new x;
x = g_number[id][0]

and "x" is the value(number)!


All times are GMT -4. The time now is 21:30.

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