OnPlayerUpdate message?
#1

Hello all i have created an simple drag map/race
and i have created an script for auto finish race
here is the script of auto finish:

Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 30.0, 4621.3721,-5468.7544,16.0294))
		{
		GivePlayerMoney(playerid, LiveMoney);
		SendClientMessage(playerid,0x21DD00FF,"[Greats]: You have FINISHED the /drag race!");
		SetPlayerPos(playerid,1359.2667,-2667.1755,13.5391);
		new pName[MAX_PLAYER_NAME];
		new string[128];
		GetPlayerName(playerid, pName, 30);
		format(string, 128, "{09FE00}[Race]: {FFFFFF}%s {09FE00}have finished the {FFFFFF}(/drag){09FE00} race.", pName);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string);
		}
    return 1; // Send this update to other players.
}
And if i am in Range of point i get some messages.


But.. i need just 1 message not a spam with Finish race (messages)

I need help
(SORRY FOR MY BAD ENGLISH)
IF ANYONE HELP ME HE GET +1
Reply
#2

anyone help in this script?
Reply
#3

Stop bumping your threads in atleast 12/24 hours.
OnPlayerUpdate gets called +- 12 times a SECOND. That means, each time you are at that position, you should get that message 12 times a second. Create a variable which wil stop sending the messages.
Reply
#4

give me the code please and i swear i do not bumped ever!
Reply
#5

The code is in your first post.
Just create a variable, and the first time when you get there a variable changes, and stops sending the message
pawn Код:
new StopMessage = 0;

if( StopMessage == 0 )
{
    StopMessage = 1;
    SendClientMessage(playerid, -1, "Message is still sending");
}
else
{
    SendClientMessage(playerid, -1, "Above message stopped sending, now this one is sending");
}
Have fun
Reply
#6

Hey wesley i need a litle more help from you can do this completly with my script
Please!
Reply
#7

Yes i can, but im not gonna do it.
Give it some tries, post some of the tries you did, and then im gonna help.
Reply
#8

Thats here is my try
Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 30.0, 4621.3721,-5468.7544,16.0294))
		{
  		GivePlayerMoney(playerid, LiveMoney);
  		SetPlayerPos(playerid,1359.2667,-2667.1755,13.5391);
		}
		new StopMessage = 0;
		if( StopMessage == 0 )
		{
		    StopMessage = 1;
		}
		else
		{
  		SendClientMessage(playerid,0x21DD00FF,"[Greats]: You have FINISHED the /drag race!");
  		new pName[MAX_PLAYER_NAME];
		new string[128];
		GetPlayerName(playerid, pName, 30);
		format(string, 128, "{09FE00}[Race]: {FFFFFF}%s {09FE00}have finished the {FFFFFF}(/drag){09FE00} race.", pName);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string);
		}

    return 1; // Send this update to other players.
}
But its dont work
Reply
#9

Lol?

pawn Код:
new bool:StopMessage[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    if(!StopMessage[playerid])
    {
        if(IsPlayerInRangeOfPoint(playerid, 30.0, 4621.3721,-5468.7544,16.0294))
        {
            GivePlayerMoney(playerid, LiveMoney);
            SetPlayerPos(playerid,1359.2667,-2667.1755,13.5391);
        }
       
        else
        {
            SendClientMessage(playerid,0x21DD00FF,"[Greats]: You have FINISHED the /drag race!");
            new pName[MAX_PLAYER_NAME];
            new string[128];
            GetPlayerName(playerid, pName, 30);
            format(string, 128, "{09FE00}[Race]: {FFFFFF}%s {09FE00}have finished the {FFFFFF}(/drag){09FE00} race.", pName);
            SendClientMessageToAll(COLOR_LIGHTBLUE, string);
            StopMessage[playerid] = true;
        }
    }
    return true;
}
Think now where to put = false;

edit://
This code is a little stupid like for me. I'd rather make it other way but how you wan't..
Reply
#10

Quote:
Originally Posted by HotPlayer
Посмотреть сообщение
Thats here is my try
Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 30.0, 4621.3721,-5468.7544,16.0294))
		{
  		GivePlayerMoney(playerid, LiveMoney);
  		SetPlayerPos(playerid,1359.2667,-2667.1755,13.5391);
		}
		new StopMessage = 0;
		if( StopMessage == 0 )
		{
		    StopMessage = 1;
		}
		else
		{
  		SendClientMessage(playerid,0x21DD00FF,"[Greats]: You have FINISHED the /drag race!");
  		new pName[MAX_PLAYER_NAME];
		new string[128];
		GetPlayerName(playerid, pName, 30);
		format(string, 128, "{09FE00}[Race]: {FFFFFF}%s {09FE00}have finished the {FFFFFF}(/drag){09FE00} race.", pName);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string);
		}

    return 1; // Send this update to other players.
}
But its dont work

You need to rethink what you are doing. No one here will recommend that you do what you are trying to do in OnPlayerUpdate you must think of a better way. OnPlayerUpdate is called X amount of times in a millisecond (its actual what your OnFoot, Incar, Weapon rates are) so let say using the default setting of 40 you are running that check 40 times in a millisecond. You can get the info here: https://sampforum.blast.hk/showthread.php?pid=417583#pid417583 So you really need to think about what you are trying to do and do you need to check those conditions 40 times in a millisecond. I highly doubt it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)