Raised This Month: $ Target: $400
 0% 

One problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
conrad
Junior Member
Join Date: Jun 2007
Old 11-17-2007 , 05:28   One problem
Reply With Quote #1

Hello guys.
I have problem with my script.
Source:

Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>

#define PLUGIN "plugin"
#define VERSION "1.0"
#define AUTHOR "By conrad"

new Sql:dbc;
new Result:res;

public plugin_init() {
 register_plugin(PLUGIN, VERSION, AUTHOR)
 register_dictionary("csbank.txt")
 register_clcmd("say /money", "saymoney", 0, "- displays hoe much money I have ")
 
 // Add your code here...
}


public sql_init() 
{

dbc = dbi_connect("localhost", "login", "password", "db")
    
    if (dbc == SQL_FAILED)
    {
        server_print("[AMXX] %L", LANG_SERVER, "SQL_SERVER_DOWN")
    }
    else
    {
       server_print("[AMXX] %L", LANG_SERVER, "SQL_SERVER_UP")
    }
     
}


public saymoney(id)
{
  new szAuthid[32], szName[32], szMoney[32];
  get_user_authid( id, szAuthid, 31 );
  get_user_name( id, szName, 31 );
 

res = dbi_query(dbc, "SELECT `money` FROM table where name='%s' ", szName); 


 while (dbi_nextrow(res) > 0)
 {  
  dbi_result(res, "money", szMoney, 31)
 }
 


client_print(0,print_chat, szMoney);
 
}
It doesn't return any result back. What is the problem?
conrad is offline
kim_perm
Member
Join Date: Sep 2007
Location: Perm, Russia
Old 11-17-2007 , 16:39   Re: One problem
Reply With Quote #2

Hello. May be
Code:
client_print(id, print_chat, szMoney);
?

Last edited by kim_perm; 11-17-2007 at 17:08.
kim_perm is offline
Old 11-17-2007, 16:48
Lee
This message has been deleted by Lee.
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-17-2007 , 17:23   Re: One problem
Reply With Quote #4

1. I don't see where you store money in table.
2. szMoney is a string, so you should do
Code:
client_print(id, print_chat, "%d", str_to_num(szMoney));
3.I think you should make szMoney a integer.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-17-2007 , 21:26   Re: One problem
Reply With Quote #5

Quote:
Originally Posted by Alka View Post
2. szMoney is a string, so you should do
Code:
client_print(id, print_chat, "%d", str_to_num(szMoney));
So you think he should convert the string to an int, to fit it in a string?
[ --<-@ ] Black Rose is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-18-2007 , 04:14   Re: One problem
Reply With Quote #6

Wut? In sql table you can put integers too...lawl. So will be:
Code:
new iResult;
iResult = dbi_result(retsult, "Name");
Oh, nvm, why not Black Rose ?! o.O
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
conrad
Junior Member
Join Date: Jun 2007
Old 11-18-2007 , 05:32   Re: One problem
Reply With Quote #7

1. Money there is by default in the table.
2. It's integer. Why do you think, that there is a string? In the table there is an integer.

About ID - while I'm testing, I'm using ID 0 - if ID is null, the message shows to all players.


Alka it aint working.
conrad is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-18-2007 , 06:01   Re: One problem
Reply With Quote #8

Quote:
Originally Posted by conrad View Post
1. Money there is by default in the table.
2. It's integer. Why do you think, that there is a string? In the table there is an integer.

Alka it aint working.
If money is a int then you must do my way. Take a look at wiki, "dbi_result"...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
conrad
Junior Member
Join Date: Jun 2007
Old 11-18-2007 , 07:15   Re: One problem
Reply With Quote #9

Error:
Quote:
warning 217: loose indentation
warning 217: loose indentation
warning 217: loose indentation
warning 217: loose indentation
error 035: argument type mismatch (argument 3)
warning 204: symbol is assigned a value that is never used: "iResult"


Code:
public saymoney(id)
{
  new szAuthid[32], szName[32];
  new iResult;
  get_user_authid( id, szAuthid, 31 );
  get_user_name( id, szName, 31 );
 

res = dbi_query(dbc, "SELECT `money` FROM table where name='%s' ", szName); 


 while (dbi_nextrow(res) > 0)
 {
   
  iResult = dbi_result(res, "money");
  
 }
 


client_print(0,print_chat, iResult);
 
}
conrad is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-18-2007 , 08:52   Re: One problem
Reply With Quote #10

Duh...this is my first time when i use "dbi" lol , but with wiki i've maded this...

Code:
#include <amxmodx>
#include <dbi>
 
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
 
new Sql:Dbc;
 
public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR);
 
 register_clcmd("say /money", "ShowMoney");
}
 
public plugin_cfg()
{
 Dbc = dbi_connect("localhost", "login", "password", "db");
 
 if(Dbc == SQL_FAILED)
 {
  dbi_close(Dbc);
  return;
 }
}
 
public plugin_end()
 dbi_close(Dbc);
 
public ShowMoney(id)
{
 new szName[32];
 get_user_name(id, szName, sizeof szName - 1);
 
 new Result:HandleR, iResult;
 HandleR = dbi_query(Dbc, "SELECT `money` FROM table where name='%s' ", szName);
 
 while(dbi_nextrow(HandleR) > 0)
 {
  iResult = dbi_result(HandleR, "money");
 }
 
 if(iResult > 0)
  client_print(id, print_chat, "%d", iResult);
}
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 11-18-2007 at 09:38.
Alka is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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