SA-MP Forums Archive
Respawn - 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: Respawn (/showthread.php?tid=413024)



Respawn - DerickClark - 03.02.2013

It not showing the Message


Код:
CMD:respawnallcars(playerid, params[])
{
    #pragma unused params
    if(APlayerData[playerid][PlayerLevel] < 3)
    {
        SendClientMessage(playerid, 0xFF0000FF, "ERROR:You can't use this command!");
    }
    else
    {
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);
        for(new i = 0; i < MAX_VEHICLES; i++)
        {
            if(IsVehicleOccupied(i) == 0)
            {
                SetVehicleToRespawn(i);
                PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
                SendClientMessage(i, 0xFFFF00FF, str);
            }
        }
    }
    return 1;
}



Re: Respawn - DerickClark - 03.02.2013

it don't show
Код:
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);



Re: Respawn - LarzI - 03.02.2013

Put the last SendClientMessage function call outside the loop.


Re: Respawn - detter - 03.02.2013

change

Код:
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);
to

Код:
new str[128] ,adminName[MAX_PLAYER_NAME];
GetPlayerName(playerid, adminName, sizeof(adminName));
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", adminName);



Re: Respawn - LarzI - 03.02.2013

Quote:
Originally Posted by detter
Посмотреть сообщение
change

Код:
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);
to

Код:
new str[128] ,adminName[MAX_PLAYER_NAME];
GetPlayerName(playerid, adminName, sizeof(adminName));
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", adminName);
Why? He's saving memory by just using one string, so his method is better. This is totally irrelevant to his problem.


Re: Respawn - detter - 03.02.2013

Код:
GetPlayerName(playerid, str, sizeof(str));
^ STR now holds admin name!

row later

Код:
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);
^ value of STR is now changed and no longer holds admin name


Re: Respawn - MarkoN - 03.02.2013

Try it with foreach, like this
pawn Код:
CMD:respawnallvehicles(playerid, params[])
{
    new string[128], name[MAX_PLAYER_NAME];
    if(APlayerData[playerid][PlayerLevel] < 3) return SendClientMessage(playerid, 0xFF0000FF, "Error : You don't have the required level to execute this command");
   
    GetPlayerName(playerid, name, sizeof(name));
   
    foreach(Player, a)
    {
        if(!IsPlayerInAnyVehicle(a))
        {
            for(new i = 0; i != MAX_VEHICLES; i++)
            {
                SetVehicleToRespawn(i);
            }
        }
    }
    format(string, sizeof(string), "Admin %s[%d] respawned all unoccupied vehicles.", name, playerid);
    SendClientMessageToAll(0xFFFF00FF, string);
    return true;
}



Re: Respawn - LarzI - 03.02.2013

Quote:
Originally Posted by detter
Посмотреть сообщение
Код:
format(str, sizeof(str), "%s has respawned all unoccupied vehicles", str);
^ value of STR is now changed and no longer holds admin name
You have no idea what you're talking about.


Re: Respawn - T0pAz - 03.02.2013

Here you go.

pawn Код:
CMD:respawnallcars(playerid, params[])
{
    #pragma unused params
    if(APlayerData[playerid][PlayerLevel] < 3)
    {
        SendClientMessage(playerid, 0xFF0000FF, "ERROR:You can't use this command!");
    }
    else
    {
        new str[64], strPName[24];
        GetPlayerName(playerid, strPName, sizeof(strPName));
        format(str, sizeof(str), "%s has respawned all unoccupied vehicles", strPName);
        for(new i = 0; i < MAX_VEHICLES; i++)
        {
            if(IsVehicleOccupied(i) == 0)
            {
                SetVehicleToRespawn(i);
            }
        }
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        SendClientMessage(playerid, 0xFFFF00FF, str);
    }
    return 1;
}



Re: Respawn - detter - 03.02.2013

Quote:
Originally Posted by LarzI
Посмотреть сообщение
You have no idea what you're talking about.
wierd ,last time i tryed that it wasn't working but its good now...

sorry for misleading you