AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making str_to_num cycle in client_PostThink (https://forums.alliedmods.net/showthread.php?t=27598)

Stephen 04-25-2006 09:18

Making str_to_num cycle in client_PostThink
 
Code:
public client_PostThink(id) {     if (FxArray[id]==1)     {     new scale[12], brightness[12]     read_argv(1, scale, 11)     read_argv(2, brightness, 11)     new origin[3];     get_user_origin(id,origin);     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);     write_byte(TE_SPRITE);     write_coord(origin[0]);     write_coord(origin[0] -= 1);     write_coord(origin[0] += 1);     write_short(sprite); // short (sprite index)     write_byte(str_to_num(scale)); // byte (scale in 0.1's)       write_byte(str_to_num(brightness)); // byte (brightness)     message_end();          }     else if (FxArray[id]==0)     {     }     return PLUGIN_CONTINUE }

When i set the scale and brightness right into the plugin it works.
But when i wanna use the code with str_to_num it only plays 1 cycle and then it dissapears again.

While this snippet works but not customaizable via the ingame console.
Code:
public client_PostThink(id) {     if (FxArray[id]==1)     {     new origin[3];     get_user_origin(id,origin);     message_begin(MSG_BROADCAST,SVC_TEMPENTITY);     write_byte(TE_SPRITE);     write_coord(origin[0]);     write_coord(origin[0] -= 1);     write_coord(origin[0] += 1);     write_short(sprite); // short (sprite index)     write_byte(6); // byte (scale in 0.1's)       write_byte(111); // byte (brightness)     message_end();          }     else if (FxArray[id]==0)     {     }     return PLUGIN_CONTINUE }

So HOW do i make it so i can use str_to_num in the snippet without vanishing after 1 cycle ?

Hawk552 04-25-2006 09:22

Try printing the values to check if there's an error in your code.

Stephen 04-25-2006 09:47

Code:
set_hudmessage(200, 200, 0, 0.55, 0.03, 0, 6.0, 6.0, 0.1, 0.1, -1)     show_hudmessage(id, "scale: %d | brightness: %d",scale,brightness)      set_hudmessage(200, 200, 0, 0.55, 0.05, 0, 6.0, 6.0, 0.1, 0.1, -1)     show_hudmessage(id, "scale: %s | brightness: %s",scale,brightness)     set_hudmessage(200, 200, 0, 0.55, 0.07, 0, 6.0, 6.0, 0.1, 0.1, -1)     show_hudmessage(id, "scale: %f | brightness: %f",scale, brightness)     set_hudmessage(200, 200, 0, 0.55, 0.09, 0, 6.0, 6.0, 0.1, 0.1, -1)     show_hudmessage(id, "scale: %c | brightness: %c",scale,brightness)     }

i used this to show me Infos about it. But i got no usefull info of it. Its not even show the values i used.
i command scale brightness( command 5 111) but i got some number of 243 and 5 etc. displayed nothing where could help me somehow. but the MSG is still playing otherwise it would show 0 the whole time.

could it be that i have use DispatchSpawn( );
somehow ? or what ?

Hawk552 04-25-2006 09:53

If the values aren't showing, then there must be an error in your code.

Stephen 04-25-2006 09:55

But where ?
cause when i set the values right away in the plugin (without str_to_num) then there is no problem with the Sprite beeing displayed and it cycles so long till i stop it.

But the str_to_num only plays 1 cycle. :cry:

p3tsin 04-25-2006 10:43

umm.. theres no arguments to read with read_argv in client_PostThink() coz its a forward :?

Stephen 04-25-2006 10:48

Is there any other way ? I know its possible cause i have seen it beeing able to custom choose the scale and brightness in the console and haveing the same effect.

I also tried it with set_task.

p3tsin 04-25-2006 10:56

Code:
new cv_scale new cv_brightness public plugin_init() {     cv_scale = register_cvar("spr_scale", "6")     cv_brightness = register_cvar("spr_brightness", "111") }

Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);     write_byte(TE_SPRITE);     write_coord(origin[0]);     write_coord(origin[0] -= 1);     write_coord(origin[0] += 1);     write_short(sprite); // short (sprite index)     write_byte(get_pcvar_num(cv_scale)); // byte (scale in 0.1's)       write_byte(get_pcvar_num(cv_brightness)); // byte (brightness)     message_end();

Greenberet 04-25-2006 11:15

I could be wrong, but you could get an message overflow if you use this in pre/postthink
I think it would be better if you use an cmd for t his

Stephen 04-25-2006 11:23

The cvar thinggy crashes me to the desktop.

Hmms. Too bad it aint possible for me to make it how i want it.

*looks at Greenberet :D

its this effect where i wanna be able to choose ingame the scale and brightness
[img]http://img88.**************/img88/3690/unbenannt3dv.th.jpg[/img]

When i use str_to_num it creates the scale and brightness i choosed, but it stays at the position then and only plays 1 cycle.


But when i set the scale and the brightness in the plugin without str_to_num
It follows me like i want it too and it isnt stopping after 1 cycle.


All times are GMT -4. The time now is 05:02.

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