Raised This Month: $ Target: $400
 0% 

Can't find the problem! :S


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-22-2005 , 00:12   Can't find the problem! :S
Reply With Quote #1

Hey All

I've been working on this problem for a while now... Right now it's midnight, and I started around 21:00 (9:00PM). I can't figure it out, and i'm going to bed; but maybe someone can help me. The problem I think is something to do with vault. It ocuurs hen I load someones exp. The save debug messages look fine. But when I load it the debugs are bad. (e.x. "Exp data () loaded for user: (username)" "Current exp = 0" )

I cannot figure this out, because the code seems perfect to me. Here it is, there's a lot but i'll try only to post what's relevant.

Code:
//Admin Function To Give User Exp. public SetExp(id, lvl, cid) {     //authenticicate     if(!cmd_access(id,lvl,cid,2) )         return PLUGIN_CONTINUE         //read parameters from command     new strTargetID[2], strExp[8]     new TargetID, Exp         read_argv(1, strTargetID, 2)     read_argv(2, strExp, 8)         TargetID = str_to_num (strTargetID)     Exp = str_to_num (strExp)         //set and save player's exp     PlayerExp[TargetID] = Exp     SaveExp(TargetID)         //debug     client_print(id, print_console, "Set user's exp to %i", PlayerExp[TargetID])         CheckLevel(TargetID)         return PLUGIN_HANDLED } //Admin Procedure To Load Someone's Exp public GetExp(id,lvl,cid) {     //authenticicate     if(!cmd_access(id,lvl,cid,1) )         return PLUGIN_CONTINUE             //read parameters from command     new strTargetID[2]     new TargetID     read_argv(1, strTargetID, 2)     TargetID = str_to_num(strTargetID)         //get name     new TargetName[34]     get_user_name(TargetID, TargetName, 33)         //show exp     LoadExp(TargetID)     client_print(id, print_console, "%s (%i) currenty has %i exp!", TargetName, TargetID, PlayerExp[TargetID])         return PLUGIN_HANDLED } //Save Exp Procedure public SaveExp(id) {             //get user AuthID     new AuthID[34], key[99], data[99]     get_user_authid(id, AuthID, 33)         format(key, 98, "%s_exp", AuthID)     format(data, 98, "%s", PlayerExp[id])     set_vaultdata (key, data)         //Debug     client_print (0, print_console, "Exp data saved for user: %s", AuthID) } //Load Exp Procedure public LoadExp(id) {     //get user AuthID     new AuthID[34], value[9]     new key[99]         get_user_authid(id, AuthID, 33)         format(key, 98, "%s_exp", AuthID)         get_vaultdata(key, value, 8)     PlayerExp[id] = str_to_num(value)         //Debug     client_print (0, print_console, "Exp data (%s) loaded for user: %s", value, AuthID)     client_print (0, print_console, "Current exp = %i", PlayerExp[id]) }

I always get () as the data in the debug message, which sets exp to 0.
For interests sake, I can save and load the players alliance fine:

Code:
//Save Alliance public SaveAlliance(id) {     //get user AuthID     new AuthID[34]     new key[99], data[99]     get_user_authid(id, AuthID, 33)         format(key, 98, "%s_alliance", AuthID)     format(data, 98, "%i", PlayerAlliance[id])     set_vaultdata (key, data)         //Debug     client_print (0, print_console, "Alliance data (%s) saved for user: %s", data, AuthID)     } //Load Alliance public LoadAlliance(id) {     //get user AuthID     new AuthID[34], value[9]     new key[99]         get_user_authid(id, AuthID, 33)         format(key, 98, "%s_alliance", AuthID)         get_vaultdata(key, value, 8)     PlayerAlliance[id] = str_to_num(value)         //Debug     client_print (0, print_console, "Alliance data (%s) loaded for user: %s", value, AuthID) } //Menu to choose new alliance (shows old alliance too) public SetAlliance(id, key) {     //key will start at zero     if (key == 0)     {         PlayerAlliance[id] = 1         client_print(id, print_chat, "You will now train for the Zionists!")         SaveAlliance(id)           }     else if (key == 1)     {         PlayerAlliance[id] = 2         client_print(id, print_chat, "You will now train for the Machines!")         SaveAlliance(id)     } else if (key == 2)     {          PlayerAlliance[id] = 3         client_print(id, print_chat, "You will now train for the Exiles!")         SaveAlliance(id)     }     else if (key == 3)     {         return PLUGIN_HANDLED     }     SaveAlliance(id)     return PLUGIN_HANDLED }

The alliance code works fine, saves, loads and displays like it should. The experience code at the top does not. Can someone tell me why?

OFFTOPIC:
How does the set_hudmessage function work?

This code displays the message at the top left of the screen:
Code:
set_hudmessage(255, 255, 255, 2, 1, 0, 6.0, 25.0, 0.1, 0.2, 4)

While this code displays it at the bottom right
Code:
set_hudmessage(255, 255, 255, 2.0, 1.0, 1, 6.0, 25.0, 0.1, 0.2, 4)

The only difference I see is the latter one has decimals, and has the effect set to 1. That shouldn't make such a huge difference should it?
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
slurpycof
Senior Member
Join Date: Nov 2004
Old 04-22-2005 , 02:34  
Reply With Quote #2

in this
Code:
public SaveExp(id) {             //get user AuthID     new AuthID[34], key[99], data[99]     get_user_authid(id, AuthID, 33)         format(key, 98, "%s_exp", AuthID)     format(data, 98, "%s", PlayerExp[id])     set_vaultdata (key, data)         //Debug     client_print (0, print_console, "Exp data saved for user: %s", AuthID) }

you are formatting data to use a number as a string. You should do a num_to_str before you store it.
Code:
//Save Exp Procedure public SaveExp(id) {             //get user AuthID     new AuthID[34], key[99], data[99],tmp_PlayerExp[32]     get_user_authid(id, AuthID, 33)         num_to_str(PlayerExp[id],tmp_PlayerExp,31)     format(key, 98, "%s_exp", AuthID)     format(data, 98, "%s", tmp_PlayerExp)     set_vaultdata (key, data)         //Debug     client_print (0, print_console, "Exp data saved for user: %s", AuthID) }
slurpycof is offline
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-22-2005 , 07:58  
Reply With Quote #3

Thanx man

That worked, but now i'm confused as hell. Why don't I have to do that with Alliance as well? It works fine. Anyways, now I am getting array index out of bounds errors like you wouldn't believe. I'll work on it after school, but if anything pops into your head please post.

When I join the server (in console)
Quote:
Smooth Criminal | Tunes connected
Smooth Criminal | Tunes is joining the Terrorist force
Player #0 lost a level. They are now level #0
Exp data (0) loaded for user: STEAM_0:1:2037446
Current exp = 0
Alliance data (0) loaded for user: STEAM_0:1:2037446
Scoring will not start until both teams have players
] ma_Playeres
Unknown command: ma_Playeres
Type 'amx_langmenu' in the console to display a menu where you can choose your language
] ma_Players
The following 1337 players are online now:
#1 - Smooth Criminal | Tunes - STEAM
When I Join the Server (in server):
ok so as i type this post it works.. i'll scroll up and find it:

Quote:
L 04/22/2005 - 07:473: [AMXX] Run time error 4 (index out of bounds) on line 63 (file "ma_playerdata.inc").
line 63 = num_to_str(PlayerExp[id],tmp_PlayerExp,31)

hmmm :S the only array in there is PlayerExp[id] which goes from 0 to 32
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-22-2005 , 14:07  
Reply With Quote #4

Code:
//read parameters from command new strTargetID[2], strExp[8] new TargetID, Exp       read_argv(1, strTargetID, 2) read_argv(2, strExp, 8)
Memory problems!

Remember to save the last character for the string terminator. Increase your strTargetID size to 3 and your strExp size to 9, but leave your read_argv's the same.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-22-2005 , 16:21  
Reply With Quote #5

ahh.. didn't know that, thanx. Also, i'm still wondering about how the coords work on set_hudmessage. I need top left, top center, and top right. It would be nice if someone could explain the system to me though.
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-22-2005 , 16:26  
Reply With Quote #6

There's a plugin that will help you get the coords.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 09:57.


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