Raised This Month: $32 Target: $400
 8% 

Help (SQL)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-29-2012 , 12:13   Help (SQL)
Reply With Quote #1

Hi all, I trying to make this plugin:

Code:
#include <amxmodx> #include <amxmisc> #include <sqlx> enum _:ServerTypes {     _Server_IP,     _Server_Players,     _Server_Data }; new ServerData[ServerTypes]; new Handle:SQLTuple; public plugin_init() {     register_clcmd("say /need", "Need");         PrepareDatabase(); } PrepareDatabase() {     SQLTuple = SQL_MakeStdTuple();         new Query[512];     formatex(Query,     charsmax(Query),     "CREATE TABLE IF NOT EXISTS need (serverip VARCHAR(32), players INT(10), data VARCHAR(32)");         SQL_ThreadQuery(SQLTuple, "QueryDefaultHandle", Query); } SaveData() {     new Query[512];         formatex(Query, charsmax(Query),     "REPLACE INTO need (serverip, players, data) VALUES ('%s', %i, '%s')",     ServerData[_Server_IP],     ServerData[_Server_Players],     ServerData[_Server_Data]     );         SQL_ThreadQuery(SQLTuple, "QueryDefaultHandle", Query); } public QueryDefaultHandle(FailState, Handle:Query, Error[], ErrorCode, Data[], DataSize, Float:QueueTime) {     switch(FailState)     {         case TQUERY_CONNECT_FAILED:         {             set_fail_state("SQL: Connection failed.");         }         case TQUERY_QUERY_FAILED:         {             log_amx("SQL: Query failed. Error: %s (%i)", Error, ErrorCode);         }     } } public Need(id) {     new PlayersNum, MinPlayers;     PlayersNum = get_playersnum();     MinPlayers = 12;         if(PlayersNum < MinPlayers) {         new ServerIP[60], Date[9], PlayersNeed;         get_user_ip(0, ServerIP, sizeof(ServerIP) - 1)         PlayersNeed = (MinPlayers - PlayersNum);         get_time("%d/%m/%Y - %H:%M:%S", Date, 8);                 ServerData[_Server_IP] = ServerIP;         ServerData[_Server_Players] = PlayersNeed;         ServerData[_Server_Data] = Date;         SaveData();     } }

But, I have error on this lines:

Code:
ServerData[_Server_IP] = ServerIP;

And:

Code:
ServerData[_Server_Data] = Date;

[code]error 006: must be assigned to an array[/quote]

Anyone help-me to fix this plugin?

Thanks

Last edited by kramesa; 05-29-2012 at 12:13.
kramesa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-29-2012 , 12:43   Re: Help (SQL)
Reply With Quote #2

You are trying to copy an variable that is an array into a variable that is not an array.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-29-2012 , 13:20   Re: Help (SQL)
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
You are trying to copy an variable that is an array into a variable that is not an array.
Ok and how I fix this?

Last edited by kramesa; 05-29-2012 at 13:34.
kramesa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-29-2012 , 13:46   Re: Help (SQL)
Reply With Quote #4

Use copy to copy it to another array.

Example

PHP Code:
new ServerData[ServerTypes][23];
....
        new 
ServerIP[23], Date[23], PlayersNeed;
        
get_user_ip(0ServerIPsizeof(ServerIP) - 1)
        
PlayersNeed = (MinPlayers PlayersNum);
        
get_time("%d/%m/%Y - %H:%M:%S"Datecharsmax(Date));
        
        
copy(ServerData[_Server_IP], charsmax(ServerData[_Server_IP]), ServerIP);
        
ServerData[_Server_Players][0] = PlayersNeed;
        
copy(ServerData[_Server_Data], charsmax(ServerData[_Server_Data]), Date); 
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-29-2012 , 13:51   Re: Help (SQL)
Reply With Quote #5

Ok, i will try, ty.

Last edited by kramesa; 05-29-2012 at 14:05.
kramesa is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-29-2012 , 14:05   Re: Help (SQL)
Reply With Quote #6

Well, the plugin don't works
kramesa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-29-2012 , 14:15   Re: Help (SQL)
Reply With Quote #7

Did you update the rest of the plugin? I'm not going to correct your entire plugin for you, this is "Scripting Help" after all.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-29-2012 , 14:33   Re: Help (SQL)
Reply With Quote #8

Quote:
Originally Posted by YamiKaitou View Post
Did you update the rest of the plugin? I'm not going to correct your entire plugin for you, this is "Scripting Help" after all.
Well, can anyone fix the part of MySQL?
kramesa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-29-2012 , 14:36   Re: Help (SQL)
Reply With Quote #9

Show us your current code after the changes. Also describe the "don't works" part.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-30-2012 , 11:51   Re: Help (SQL)
Reply With Quote #10

The code is the same, only with your part modified.
kramesa is offline
Reply


Thread Tools
Display Modes

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 20:15.


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