AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Format Function Assigns To Every Key (https://forums.alliedmods.net/showthread.php?t=45524)

Minimum 10-04-2006 17:20

Format Function Assigns To Every Key
 
Heres the problem. When I execute the format functions they format every key of the array. Which makes everyone see the text. And when I make it equal it just shows a random letter because it thinks its an integer. Any suggestions?

Code:
public hud_print(id,message[]) {     if(id == 0) {         new x, players[32]         get_players(players,x,"ac")         for( new i = 0;  i < x; i++ ) {             new playerindex = players[i]             format(hudmsg4[playerindex],127,"%s",hudmsg3[playerindex])             format(hudmsg3[playerindex],127,"%s",hudmsg2[playerindex])             format(hudmsg2[playerindex],127,"%s",hudmsg1[playerindex])             format(hudmsg1[playerindex],127,"%s",message)         }         return PLUGIN_HANDLED     } // Integer Stuff Pt. 1     new message2[128]     format(message2[id],127,"%s",message) // Formatting stuff     //format(hudmsg4[id],127,"%s",hudmsg3[id])     //format(hudmsg3[id],127,"%s",hudmsg2[id])     //format(hudmsg2[id],127,"%s",hudmsg1[id])     //format(hudmsg1[id],127,"%s",message) // Integer Stuff Pt. 2     hudmsg4[id] = hudmsg3[id]     hudmsg3[id] = hudmsg2[id]     hudmsg2[id] = hudmsg1[id]     hudmsg1[id] = message2[id]     return PLUGIN_HANDLED }

stupok 10-04-2006 18:23

Re: Format Function Assigns To Every Key
 
I am not certain, but I think 0 is a valid number for id, but I don't know why you would do: if(id == 0)...

From the look of it, all players should receive the message since 0 is a vaild number for id, so the lines in the 'if' statement will always be executed.

I don't understand the point of have 4 different "hudmsg" when you do
Code:
hudmsg4[id] = hudmsg3[id]     hudmsg3[id] = hudmsg2[id]     hudmsg2[id] = hudmsg1[id]     hudmsg1[id] = message2[id]

What is this code supposed to do?

TheNewt 10-04-2006 18:24

Re: Format Function Assigns To Every Key
 
0 is valid, its server if I'm not mistaken.

Minimum 10-04-2006 19:12

Re: Format Function Assigns To Every Key
 
Its the text console on the bottom left.

http://minimum.gabionstudios.com/images/ts-25.jpg

When I send 0 to the function's id I make it execute the code in the if(id == 0).

XxAvalanchexX 10-04-2006 21:31

Re: Format Function Assigns To Every Key
 
I notice that:
Code:
new message2[128] format(message2[id],127,"%s",message)
should most likely be:
Code:
new message2[128] format(message2,127,"%s",message)

Also, how are you declaring your hudmessage1...4 variables? Based on how it seems you want to make your code act, make sure they are two-dimensional: hudmessage1[33][128] for example, otherwise you would run into the same thing as above.


All times are GMT -4. The time now is 04:56.

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