SCM after respawn cars
#1

Hey,

How to send a client message after that the cars are respawned,
I mean I know how but when I did, it spammed the chat full of the SCM.

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    for(new car = 1; car <= 268; car++)
    {
        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);
    }
    return 1;
}
Reply
#2

Did you try and think that the reason was because it was in a loop?

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    for(new car = 1; car <= 268; car++)
    {
        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);
    }
    return 1;
}
change to:

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    for(new car = 1; car <= 268; car++)
    {
        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
    }
    format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
    SendClientMessageToAll(RED, string);
    return 1;
}
Try now.
Reply
#3

Just one little thing, Never put text inside loops, it may spam your chat over and over, unless you want that.
Reply
#4

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Did you try and think that the reason was because it was in a loop?

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    for(new car = 1; car <= 268; car++)
    {
        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);
    }
    return 1;
}
change to:

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    for(new car = 1; car <= 268; car++)
    {
        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
    }
    format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
    SendClientMessageToAll(RED, string);
    return 1;
}
Try now.
Now it works but, even normal players can /rac but then the cars not respawn but it sends the "SERVER ACTION ......"
Reply
#5

Try this

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    {
        for(new car = 1; car <= 268; car++)
        {
            if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        }
        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);
    }
    else
    {
        SendClientMessage(playerid,RED,"You are not an Admin and can't respawn cars!");
    }
    return 1;
}
Reply
#6

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    {
        for(new car = 1; car <= 268; car++)
            if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);

        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);        
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by MarinacMrcina
Посмотреть сообщение
Try this

pawn Код:
command(rac, playerid, params[])
{
    new string[128];
    if(Player[playerid][AdminLevel] >= 1 || Player[playerid][Moderator] >= 1)
    {
        for(new car = 1; car <= 268; car++)
        {
            if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        }
        format(string, sizeof(string), "SERVER ACTION: All unused cars respawned by %s", GetName(playerid));
        SendClientMessageToAll(RED, string);
    }
    else
    {
        SendClientMessage(playerid,RED,"You are not an Admin and can't respawn cars!");
    }
    return 1;
}
Fixed +Rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)