Raised This Month: $ Target: $400
 0% 

Copy() problem ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-20-2007 , 15:40   Copy() problem ?
Reply With Quote #1

Hey there again, have been trying to get this copy() function to work for the past hour, but it keeps over-writing the whole variable "hud_1" with the data from the last copy string.
What am I doing wrong?

Thanks

Code:
new hud_1[256]     if(retrieve_data(g_Query[id],data) == -1)     {         format(hud_1,128," » %s ^n___________________^n Unregistered.",g_hud_1_title)     }     else     {         new jobinfo[3][32]         if(job_info(id,str_to_num(data[5]),jobinfo) == -1)         {             jobinfo[0] = "Invalid Job"             jobinfo[1] = "Invalid Job"         }                 new main[64]         format(main,63,"%s Bank # / $: %s / %s^n Wallet: %s^n ",g_hud_1_header,data[1],data[0],data[2])         copy(hud_1,63,main)                 new job_str[64]         if(equali(jobinfo[0],"")) format(job_str,63," Job: %s ^n",jobinfo[1])             else format(job_str,63,"Org: %s^n Job: %s",jobinfo[0],jobinfo[1])         copy(hud_1,63,job_str)                 new salary_str[64]         new salary = str_to_num(jobinfo[2])                 new pay_type = str_to_num(data[3])         new pay_pos = str_to_num(data[4])                 switch(pay_type)         {             case 24:             {                 format(salary_str,63," Salary: $%i^n Pay/D: $%i^n PayTimer(daily): %i/24",salary,salary*24,pay_pos)             }                         case 60:             {                 format(salary_str,63," Salary: $%i^n PayTimer(hourly): %i/60",salary,pay_pos)             }                         default:             {                 pick_paytype(id)             }         }         copy(hud_1,63,salary_str)             }         set_hudmessage(g_hud_1_rgb[0],g_hud_1_rgb[1],g_hud_1_rgb[2],g_hud_1_xy[0],g_hud_1_xy[1],0,0.0,99.0,0.0,0.0,HUD_1_CHANNEL)     show_hudmessage(id,hud_1)
__________________


Last edited by mysticssjgoku4; 01-20-2007 at 15:47.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 01-20-2007 , 16:19   Re: Copy() problem ?
Reply With Quote #2

What do you expect. It going to do that because your using a single global variable to store all those. It going to overwrite them using copy. Are you trying to put all those messages into a single variable?

Code:
new len; new message[256]; // I believe this is correct usage. len += format(message, message[len], "Message"); len += format(message, message[len], "Message");


edit
Quote:
Originally Posted by copy
copy - Copies one string to another for a maximum for len characters.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 01-20-2007 at 16:23.
teame06 is offline
Send a message via AIM to teame06
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 01-20-2007 , 17:37   Re: Copy() problem ?
Reply With Quote #3

Alright thanks. Appreciate it.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
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 22:28.


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