AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Copy() problem ? (https://forums.alliedmods.net/showthread.php?t=50146)

mysticssjgoku4 01-20-2007 15:40

Copy() problem ?
 
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)

teame06 01-20-2007 16:19

Re: Copy() problem ?
 
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.


mysticssjgoku4 01-20-2007 17:37

Re: Copy() problem ?
 
Alright thanks. Appreciate it.


All times are GMT -4. The time now is 22:28.

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