SendClientMessage timed
#1

I have this:
pawn Код:
forward SendClientMessageEx(playerid, color,msg[]);

public SendClientMessageEx(playerid, color, msg[])
{
    SendClientMessage(playerid, pgreen3, msg);
}

SetTimerEx("SendClientMessageEx",4000,0,"i,i,s",playerid,yellow3,"* string here"); //under OnPlayerConnect
But it doesn't work...It sends a blank message
I tried typing "i i s", "iis","dds" instead of "i,i,s" and nothing worked.

Btw,"iis" made my server crash

So what should be put there?
Reply
#2

do you get any errors when compililing?
Reply
#3

No.
Reply
#4

If it is a string it needs to have size defined. I think it sends you blank message because the size on msg is 0
Reply
#5

So I need "i,i,s128"(<- this doesn't work)? or what?
Reply
#6

Some strange things happen...
I've put #include <malloc>

If I paste nothing from your post, the script compiles without errors.

If I paste only this part:
pawn Код:
forward SendClientMessageEx(playerid, color, Alloc:slot);

public SendClientMessageEx(playerid, color, Alloc:slot)
{
SendClientMessage(playerid, color, mget(slot));
free(slot); // Very important
}
Compiler says about the error in malloc.inc(expected token: ")", but found "-identifier-" and some others) at line 639.

If I paste both of these 2 parts I'll get the same error in malloc.inc again but at line 415
Reply
#7

What's wrong with malloc(or my script), ******?
Reply
#8

another bump...my GM development stopped here...
Can someone help please?
Reply
#9

Passing strings in SetTimerEx appear to be causing server crashes. I made a textdraw function with an offset parameter which uses the function, but it just makes my server crash straight away.

Код:
public CreatePlayerMessage(iPlayerID,szMessage[],iSeconds,iOffset)
{
	if(IsPlayerMessageShowing(iPlayerID) && iOffset == 0)
	{
      DestroyPlayerMessage(iPlayerID);
    }

	if(iOffset > 0)
	{
	  SetTimerEx("CreatePlayerMessage", iOffset * 1000, false, "isii", iPlayerID, szMessage, iSeconds, 0);
      return;
     }

	iPlayerMessage[iPlayerID] = TextDrawCreate(191,372,szMessage);
	TextDrawUseBox(iPlayerMessage[iPlayerID],1);
	TextDrawBoxColor(iPlayerMessage[iPlayerID],0x00000000);
	TextDrawTextSize(iPlayerMessage[iPlayerID],542,23);
	TextDrawBackgroundColor(iPlayerMessage[iPlayerID],0x000000ff);
	TextDrawFont(iPlayerMessage[iPlayerID],1);
	TextDrawLetterSize(iPlayerMessage[iPlayerID],0.499999,2.000000);
	TextDrawColor(iPlayerMessage[iPlayerID],0xffffffcc);
	TextDrawSetProportional(iPlayerMessage[iPlayerID],1);
	TextDrawSetShadow(iPlayerMessage[iPlayerID],1);
	TextDrawShowForPlayer(iPlayerID,iPlayerMessage[iPlayerID]);
	iTextTime[iPlayerID][0] = iSeconds;
	iTextTime[iPlayerID][1] = GetTickCount();
}
It has got me quite annoyed. I hope SetTimerEx is fixed in 0.3.
Reply
#10

Strings are arrays. So I have a theory that maybe you could use the array ('a') parameter to pass the string ... ?

pawn Код:
SetTimerEx( "SendClientMessageEx", 4000, 0, "iia", playerid, yellow3, "xxx", 4 );

// array_len = string_length + 1; You can use "strlen( string ) + 1" for unknown string sizes? Try using "sizeof( string )" (remove the + 1) if strlen doesn't work.
// SetTimerEx( "SendClientMessageEx", 4000, 0, "iia", playerid, yellow3, string_array, array_len );
(I've never used the 'a' parameter in SetTimerEx, not quite sure how it works. It's a theory you can test though .)
Reply
#11

It doesn't work...
Probably I will have to make an array with all the strings...
Reply
#12

So by what I am reading, you want something printed in the chatbox every 4 seconds.

Lets do it like this... (I am assuming you want this message to send to all players)

1. First of all, there is no need for SendClientMessageEx because there is nothing that it is doing except adding the Ex to the end of the function name, I am going to discard this.
pawn Код:
forward SendClientMessageEx(playerid, color,msg[]);

public SendClientMessageEx(playerid, color, msg[])
{
    SendClientMessage(playerid, pgreen3, msg);
}
2.Lets define some variables
pawn Код:
new foursecondtimer;
forward FourSecondTimer();
3.Now we place our timer in our ongamemodeinit callback
pawn Код:
public OnGameModeInit()
{
  foursecondtimer = SetTimer("FourSecondTimer", 4000, true);
  return 1;
}
4.Now we create our FourSecondTimer callback
pawn Код:
public FourSecondTimer()
{
  for(new i=0; i<=GetMaxPlayers(); i++)
  {
    SendClientMessage(i, pgreen3, "string here"); // <- thanks for using my colors inc haha.
  }
  return 1;
}
Just fill in where it says "string here" with what you want printed every 4 seconds, and it works
Reply
#13

Thanks, but you're wrong. I didn't want to repeat it.
I wanted to show messages in some seconds, because showing a lot of them at the same time on connect is...confusing a bit and they can be not noticed at all.

P.S. Thanks for the color include, that is exactly what I was looking for
Reply
#14

Can you explain exactly what your trying to do then?
Reply
#15

Ehm...:
Quote:
Originally Posted by CrαcK
...I wanted to show messages in some seconds...
Like OnPlayerConnect at first a message containing "Welcome bla bla bla" is shown.
Then in 4 seconds a message " type /bla bla" is shown.
Then in 2 seconds a message " type /bla bla 2" is shown.
e.t.c.
Quote:
Originally Posted by CrαcK
...because showing a lot of them at the same time on connect is...confusing a bit
Reply
#16

I see. Well lemme add on to what I had before with a slight modding.(timer went from 4 seconds to 1 second).

pawn Код:
new TimerTick[MAX_PLAYERS];
new secondtimer;
forward SecondTimer();
forward LoginMessage(playerid);

public OnGameModeInit()
{
  secondtimer = SetTimer("SecondTimer", 1000, true);
  return 1;
}

public OnPlayerConnect(playerid)
{
  TimerTick[playerid] = 0;
  return 1;
}

public SecondTimer()
{
  for(new i=0; i<=GetMaxPlayers(); i++)
  {
    if(TimerTick[i] <= 8)
    {
      TimerTick[i]++;
      LoginMessage(i);
    }
  }
  return 1;
}

public LoginMessage(playerid)
{
  if(TimerTick[playerid] == 2)
  {
    SendClientMessage(playerid, pgreen3, "Welcome to This Server.");
    return 1;
  }
  if(TimerTick[playerid] == 4)
  {
    SendClientMessage(playerid, pgreen3, "Type /login [password] to login");
  }
  if(TimerTick[playerid] == 8)
  {
    SendClientMessage(playerid, pgreen3, "If you would like to reset your password type /resetpass [oldpass] [newpass]");
  }
  return 1;
}
This creates a variable which adds 1 every second until it hits 8. When 2 seconds go by, it will display the welcome message. When four seconds go by a second login message displays. When 8 seconds go by a third message displays.

Tell me if I got it right this time.
Reply
#17

You are right, but that will be more easy with SetTimerEx, but it doesn't work with strings...
Also there are A LOT of other messages that I want to send not immediately, and it will be very hard to modify all of the needed messages in your way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)