SA-MP Forums Archive
SCM after respawn cars - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SCM after respawn cars (/showthread.php?tid=351928)



SCM after respawn cars - Stefand - 17.06.2012

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;
}



Re: SCM after respawn cars - Kindred - 17.06.2012

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.


Re: SCM after respawn cars - leonardo1434 - 17.06.2012

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


Re: SCM after respawn cars - Stefand - 17.06.2012

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 ......"


Re: SCM after respawn cars - MarinacMrcina - 17.06.2012

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;
}



Re: SCM after respawn cars - ViniBorn - 17.06.2012

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;
}



Re: SCM after respawn cars - Stefand - 17.06.2012

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