Respawn
#1

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;
}
Reply
#2

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

Put the last SendClientMessage function call outside the loop.
Reply
#4

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);
Reply
#5

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.
Reply
#6

Код:
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
Reply
#7

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;
}
Reply
#8

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.
Reply
#9

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;
}
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)