13.05.2016, 21:31
I need the /revive command which allow admins to revive dead players
CMD:revive(playerid, params[]) { new ChosenPlayerID, Float:health; if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only admins can use this command."); // This is your admin check if (sscanf(params, "u", ChosenPlayerID)) SendClientMessage(playerid, -1, "Usage: /revive <playerid>"); if (ChosenPlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected"); GetPlayerHealth(ChosenPlayerID, health); if (health > 10.0) return SendClientMessage(playerid, -1, "This player has enough health."); SetPlayerHealth(ChosenPlayerID, 100.0); // Heal the player SendClientMessage(ChosenPlayerID, -1, "You was revived by admin."); // Inform the player that he was revived return 1; }
//=========================================================================================================
if(strcmp(cmd, "/respawn", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /respawn [playerid/PartOfName]");
return 1;
}
new playa;
playa = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
//if(SpawnChange[playerid])
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
ResetPlayerTofang(playa);
SetSpawnKol(playa);
SpawnPlayer(playa);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* You have respawned %s", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, sizeof(string), "* You have been respawned by Admin %s", sendername);
SendClientMessage(playa, COLOR_LIGHTRED, string);
format(string, 256, "AdmWarning: {FFFFFF}%s has respawned the {FFFFFF}%s", sendername, giveplayer);
ABroadCast(COLOR_YELLOW,string,1);
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREEN, "Error: Your Admin level isn't high enough to use this command!");
}
}
return 1;
}
//----------------------
I dont know what u want exactly
I use this to respawn someone ... |
CMD:respawn(playerid, params[]) { new ChosenPlayerID; if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only admins can use this command."); if (sscanf(params, "u", ChosenPlayerID)) SendClientMessage(playerid, -1, "Usage: /respawn <playerid>"); if (ChosenPlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected"); SpawnPlayer(ChosenPlayerID); SendClientMessage(SpawnPlayer, -1, "You have been respawned by admin."); return 1; }
What to you mean by reviving dead player?
I made this command to heal a chosen player if he have less than 10 HP. Код:
CMD:revive(playerid, params[]) { new ChosenPlayerID, Float:health; if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only admins can use this command."); // This is your admin check if (sscanf(params, "u", ChosenPlayerID)) SendClientMessage(playerid, -1, "Usage: /revive <playerid>"); if (ChosenPlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected"); GetPlayerHealth(ChosenPlayerID, health); if (health > 10.0) return SendClientMessage(playerid, -1, "This player has enough health."); SetPlayerHealth(ChosenPlayerID, 100.0); // Heal the player SendClientMessage(ChosenPlayerID, -1, "You was revived by admin."); // Inform the player that he was revived return 1; }
|
Was that needed? You've defined some things that he probably haven't defined. This code just won't work for him.
Anyways if you wanted a respawn command, here's a better version: Код:
CMD:respawn(playerid, params[]) { new ChosenPlayerID; if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only admins can use this command."); if (sscanf(params, "u", ChosenPlayerID)) SendClientMessage(playerid, -1, "Usage: /respawn <playerid>"); if (ChosenPlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected"); SpawnPlayer(ChosenPlayerID); SendClientMessage(SpawnPlayer, -1, "You have been respawned by admin."); SendClientMessage(SpawnPlayer, -1, "You respawned the chosen player."); return 1; } |
You command will works but you can glitch him. Set your HP between 256 - 265 and your command will work too. Why? « Even though the health can be set to near infinite values on the server side, the individual clients will only report values up to 255. Anything higher will wrap around; 256 becomes 0, 257 becomes 1, etc. » (Source : WIKI)
I don't understand what DAREL wants too. |