AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] imessage.sma problem (https://forums.alliedmods.net/showthread.php?t=61245)

James 09-25-2007 02:34

[SOLVED] imessage.sma problem
 
Hi, i want modify imessage.sma for allow show hudmessage ONLY FOR certain players. But I have problem, i cannot assign player id !

I would like modify
public infoMessage()
{

to
public infoMessage(id)
{

but i cant find place, which runs this method! Plugin_init() seems to be wrong guess.

Anybody help me ?

Wilson [29th ID] 09-25-2007 03:35

Re: imessage.sma problem
 
'id' is not used anywhere in this plugin. It is not sent from user command or interaction, and is sent globally on a regular basis.

On lines 91 and 93 are where the messages are actually sent. They are sent to client 0, which (since world doesn't care) is replaced by "every client" in the code for those functions.

Simply replace it with a loop...

Code:
for ( new i=1; i <= 32; i++ ) {     // Do your code to test if you want to send to this player or not here     if( i = chosen_one )     {         show_hudmessage(i, "%s", Message);             client_print(i, print_console, "%s", Message);     } }

James 09-25-2007 10:48

Re: imessage.sma problem
 
sent globally on a regular basis - do you know if I can change this to call something like infoMessage(id)?

Loop 32 is maybe solution too, but imho will be better to have option to recognize id in function infoMessage. On the server can be less than 32 players, maybe I can make loop through them like

public infoMessage()
{
for (new id = 1; id <= get_maxplayers(); id++) {
if (is_user_connected(id)) {


but still, seems little strange solution for me. Using id is quite usuall normal thing on Amxx, and i dont know why is infoMessage function so weird..

But anyway, thx for some way solution, if other fails, this can be solution for me.

Wilson [29th ID] 09-25-2007 11:38

Re: imessage.sma problem
 
No. You're not getting it. This is not me providing a "more efficient solution to the more patternous method." This is the only way to do it.

The way the plugin works is by regularly sending a global message, based on a time interval set by a CVAR. It does not require a user to activate the command, and thus inputs no user "id". It will occur even if there are no users in the server.

What you did in your code was change the variable name from "i" to "id". Either one would work. Most coders use "i" in a loop because it is an increasing variable and not the same type of variable as your typical "id".

And yeah, you can use get_maxplayers() instead. I was just giving you an example.

James 09-25-2007 13:36

Re: imessage.sma problem
 
Ok, i will trust you, thanks man :)


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

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