Teleport command message. [+rep]
#1

Hello everyone, i need some help from you, again!

All teleports in my server, when player teleport for example to drift1, send message to all players, that he teleport to drift1.

The code is :

pawn Код:
CMD:drift1(playerid, params[])
{
    SetPlayerInterior(playerid,0);
    SetPlayerVirtualWorld(playerid, 0);
    ResetPlayerWeapons(playerid);
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid),0);
        SetVehiclePos(GetPlayerVehicleID(playerid),-308.3555,1527.1465,75.3594);
    }
    else {
        SetPlayerPos(playerid,-350.2008,1533.3462,75.3594);
        SetPlayerFacingAngle(playerid, 208.6879);
        SetCameraBehindPlayer(playerid);
    }
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "{FFFF00}%s(%d) {FFFFFF}teleported to /drift1", name,playerid);
    SendClientMessageToAll(-1, string3);
    return 1;
}
So, i want to create a command, that will disable this for player who dont like to see it.

Any help please?

Thank you!
Reply
#2

For that, you'll need a whole new variable, which checks if player "accepts" the message. For example:
pawn Код:
new bool:ReceiveMess[MAX_PLAYERS];

CMD:togmessages(playerid, params[])
{
    if(ReceiveMess[playerid])
    {
        ReceiveMess[playerid] = false;
        SendClientMessage(playerid, -1, "You won't get any teleport messages now.");
    }
    else
    {
        ReceiveMess[playerid] = true;
        SendClientMessage(playerid, -1, "You will now receive teleport message.");
    }
    return 1;
}

// And now, under your command, use:
CMD:drift1(playerid, params[])
{
    SetPlayerInterior(playerid,0);
    SetPlayerVirtualWorld(playerid, 0);
    ResetPlayerWeapons(playerid);
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        LinkVehicleToInterior(GetPlayerVehicleID(playerid),0);
        SetVehiclePos(GetPlayerVehicleID(playerid),-308.3555,1527.1465,75.3594);
    }
    else {
        SetPlayerPos(playerid,-350.2008,1533.3462,75.3594);
        SetPlayerFacingAngle(playerid, 208.6879);
        SetCameraBehindPlayer(playerid);
    }
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "{FFFF00}%s(%d) {FFFFFF}teleported to /drift1", name,playerid);
    //You'll need a loop through all players who are online:
    for(new i; i<MAX_PLAYERS; i++)
        if(ReceiveMess[i])
            SendClientMessage(i, -1, string3);
    //now foreach
    foreach (Player, i)
        if(ReceiveMess[i])
            SendClientMessage(i, -1, string3);
           
    // KEEP IN mind, you don't need both loops. Just one of the above two. I gave you both, in case you're using foreach or regular loop
    return 1;
}
That should do it. Hope I helped.
Reply
#3

Thank you so much!! Rep added!
Reply
#4

correction to the above
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
if( IsPlayerConnected(i) )
        if(ReceiveMess[i])
            SendClientMessage(i, -1, string3);
You may also want to clear the variable OnPlayerDisconnect
Reply
#5

Quote:
Originally Posted by Rachael
Посмотреть сообщение
correction to the above
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
if( IsPlayerConnected(i) )
        if(ReceiveMess[i])
            SendClientMessage(i, -1, string3);
You may also want to clear the variable OnPlayerDisconnect
You're completely right. Sorry for the mistake.
Reply
#6

Rachael thank you, Rep added!

I want also something else if you can help me, how i can change the SERVER:Unknown Command in Zcmd?

Thank you!
Reply
#7

Using this callback:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return 0;
}
Instead of return 0; you put whatever you want. Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    return SendClientMessage(playerid, -1, "This command does not exist. Use /help for a full list of commands.");
}
Reply
#8

I try this before, but nothing happened.

*Edit: i change it and in some filterscripts that use it and now works, thank you again!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)