PDA

View Full Version : Help /aduty


gotwarzone
04/12/2013, 06:52 PM
Can someone please help me modify the following below?

It should be when I use /aduty, my name Zayn_Malik would be now Zayn. So basically when I'm on duty the last name should be removed. When I set back again to /aduty else my name should go back to Zayn_Malik.


CMD:aduty(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, -1, "This is an admin only command!");
if(PlayerInfo[playerid][pAdminDuty] == 0)
{

SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on administrative duty! Remember to check /reports!");
//SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
PlayerInfo[playerid][pAdminDuty] = 1;
SetPlayerHealth(playerid, 100000);
SetPlayerArmour(playerid, 100000);
//SetPlayerSkin(playerid, 294); - Commented by Voltage
new string[128];
format(string, sizeof(string), "Administrator %s is now on Admin Duty! (/am for assistance)", GetPlayerNameEx(playerid));
SendClientMessageToAllEx(COLOR_YELLOW, string);
}
else
{
SendClientMessageEx(playerid, COLOR_RED, "You are now off admin duty!");
//SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
//SetPlayerSkin(playerid, 299); - Commented by Voltage
PlayerInfo[playerid][pAdminDuty] = 0;
}
return 1;
}

SKAzini
04/12/2013, 07:14 PM
stock getFirstName(szPlayerName[]) {
new
_tmpSzPlayerName[MAX_PLAYER_NAME],
iCh = strfind(szPlayerName, "_", true);

if(iCh != -1) {
strcat(_tmpSzPlayerName, szPlayerName, MAX_PLAYER_NAME);
strdel(_tmpSzPlayerName, iCh, strlen(szPlayerName));
} else {
format(_tmpSzPlayerName, sizeof(_tmpSzPlayerName), "Nameless");
}

return _tmpSzPlayerName;
}

Replace PlayerInfo[playerid][pAdminName] in SetPlayerName to getFirstName(playerid).