if(strcmp(cmd, "/fine", true) == 0) { if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /fine [playerid/PartOfName] [money] <reason>"); return 1; } new playa; new money; playa = ReturnUser(tmp); tmp = strtok(cmdtext, idx); money = strval(tmp); if (PlayerInfo[playerid][pAdmin] >= 2) { if(IsPlayerConnected(playa)) { if(playa != INVALID_PLAYER_ID) { GetPlayerName(playa, giveplayer, sizeof(giveplayer)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[128]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SafeGivePlayerMoney(playa, - money); format(string, 256, "[ADMIN]: %s (%d) has been fined $%d by %s [No Reason Given].", giveplayer, playa,money, sendername); SendAdminMessage(COLOR_LIGHTRED,string); format(string, sizeof(string), "You have Fined $%d to %s (%d), No Reason Given.",money, giveplayer, playa); SendClientMessage(playerid,COLOR_LIGHTRED ,string); format(string, sizeof(string), "%s (%d), Has Been Fined $%d by %s, No Reason Given", giveplayer, playa, money, sendername); SendClientMessageToAll(COLOR_NICERED, string); format(string, sizeof(string), "~r~~h~-Admin Fined- ~n~~n~~n~~n~~n~~n~~n~~y~No reason Given ~n~Money: ~g~$%d", money); GameTextForPlayer(playa, string, 7000, 3); new y, m, d; new h,mi,s; getdate(y,m,d); gettime(h,mi,s); format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been fined by %s | Reason: None | Money: $%d |.",d,m,y,h,mi,s,giveplayer,sendername, money); PayLog(string); AdminLog(string); format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Fined by %s - Reason: None - Money: $%d .",d,m,y,h,mi,s,sendername,money); AddPunishment(playa, string); return 1; } SafeGivePlayerMoney(playa, - money); format(string, 256, "[ADMIN]: %s (%d) has been fined $%d by %s [Reason: %s].", giveplayer, playa,money, sendername, (result)); SendAdminMessage(COLOR_LIGHTRED,string); format(string, sizeof(string), "You have Fined $%d to %s (%d) for: %s .",money, giveplayer, playa, (result)); SendClientMessage(playerid,COLOR_LIGHTRED ,string); format(string, sizeof(string), "%s (%d), Has Been Fined $%d by %s for: %s", giveplayer, playa, money, sendername, (result)); SendClientMessageToAll(COLOR_NICERED, string); format(string, sizeof(string), "~r~~h~-Admin Fined- ~n~~n~~n~~n~~n~~n~~n~~y~Reason: ~w~%s ~n~Money: ~g~$%d",(result), money); GameTextForPlayer(playa, string, 7000, 3); new y, m, d; new h,mi,s; getdate(y,m,d); gettime(h,mi,s); format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been fined by %s | Reason: %s | Money: $%d |.",d,m,y,h,mi,s,giveplayer,sendername,(result),money); PayLog(string); AdminLog(string); format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Fined by %s - Reason: %s - Money: $%d.",d,m,y,h,mi,s,sendername,(result),money); AddPunishment(playa, string); } } } else { SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!"); } } return 1; }
CMD:pay(playerid, params[])
{
new pID, Amount, string[256], string1[256], transmitter[MAX_PLAYER_NAME], receivers[MAX_PLAYER_NAME];
if(sscanf(params, "ud", pID, Amount)) return SendClientMessage(playerid, COLOR_WHITE, "[CMD]:/pay [PlayerID] [Amount]");
if(pID == INVALID_PLAYER_ID) SendClientMessage(playerid, red, "[ERROR]:Player not Found or Connected!");
else
{
GetPlayerName(playerid, transmitter, sizeof(transmitter));
GetPlayerName(pID, receivers, sizeof(receivers));
format(string, sizeof(string), "* [CMD]: %s has pay you $%d *", transmitter, Amount);
SendClientMessage(pID, COLOR_WHITE, string);
format(string1, sizeof(string1), "* [CMD]: You have pay $%d to %s ", Amount, receivers);
SendClientMessage(playerid, COLOR_WHITE, string1);
GivePlayerMoney(pID, Amount);
}
return 1;
}
new reason; COMMAND:akill(playerid, params[]) { if (IsPlayerAdmin(playerid)) { new toplayerid, //the player we want to give money to amount; //extracting player's id and amount from params if (!sscanf(params, "ii", toplayerid, reason)) { if (toplayerid != INVALID_PLAYER_ID) { new message[40]; SetPlayerHealth(playerid, 0); format(message, sizeof(message), "admin killed u reason : %d", amount); SendClientMessage(toplayerid, 0x00FF00FF, message); } else SendClientMessage(playerid, 0xFF0000FF, "that player is not connected"); } else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>"); } else SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!"); return 1; } |
enum pInfo
{
pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
okay okay i started use zcmd and sscanf and givemoney problem sloved
now another problem with zcmd and sscanf look in it pawn Code:
its okay no compile errors just when i enter server i do /akill 0 blabla" its send me message "usage : /akill plaerid reason and if i do "akill 0 0" its send me message "admin killed u reason : 0" only if akill 0 0 its working why? |
CMD:akill(playerid, params[])
{
new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], Reason[128], string[256];
if(PlayerInfo[playerid][pAdmin] >= 3)
if(sscanf(params,"us",pID, Reason)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/akill [PlayerID] [Reason]");
else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid,red,"[ERROR]:Player not Found!");
else
{
GetPlayerName(playerid,aName,sizeof(aName));
GetPlayerName(pID,pName,sizeof(pName));
format(string, sizeof(string),"* Admin %s has Admin Killed %s (Reason: %s) *",aName, pName, Reason);
SendClientMessage(playerid,red,string);
SetPlayerHealth(pID,0);
}
else return SendClientMessage(playerid, red, "[ERROR]:You need to be an Admin to Access this Commands!");
return 1;
}
if(sscanf(params,"us",pID, Reason))
COMMAND: sethealth(playerid, params[]) { new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME],Amount[128], string[256]; if (IsPlayerAdmin(playerid)) if(sscanf(params,"us",pID, Amount)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/sethealth [PlayerID] [Amount]"); else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!"); else { GetPlayerName(playerid,aName,sizeof(aName)); GetPlayerName(pID,pName,sizeof(pName)); format(string, sizeof(string),"Admin Has Healed You",aName, pName, Amount); SendClientMessage(playerid,COLOR_BRIGHTRED,string) ; SetPlayerHealth(pID,%s); } else return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!"); return 1; } |
COMMAND: sethealth(playerid, params[])
{
new pID, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME],Amount[128], string[256];
if (IsPlayerAdmin(playerid))
if(sscanf(params,"us",pID, Amount)) return SendClientMessage(playerid,COLOR_WHITE,"[CMD]:/sethealth [PlayerID] [Amount]");
else if (pID==INVALID_PLAYER_ID)SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
else
{
GetPlayerName(playerid,aName,sizeof(aName));
GetPlayerName(pID,pName,sizeof(pName));
format(string, sizeof(string),"Admin Has Healed You",aName, pName, Amount);
SendClientMessage(playerid,COLOR_BRIGHTRED,string) ;
SetPlayerHealth(pID,%s);
}
else return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
return 1;
}
COMMAND:akill(playerid, params[])
{
new toplayerid, reason[64], message[128];
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "only admins can use this command!");
if(sscanf(params, "ds[64]", toplayerid, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /akill <plaerid> <reason>");
if(toplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "that player is not connected");
SetPlayerHealth(playerid, 0);
format(message, sizeof(message), "Admin killed u reason : %s", reason);
SendClientMessage(toplayerid, 0x00FF00FF, message);
return 1;
}
COMMAND:sethealth(playerid, params[])
{
new pID, amount, aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME], string[256];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "[ERROR]:You need to be an Admin to Access this Commands!");
if(sscanf(params, "dd", pID, Amount)) return SendClientMessage(playerid, COLOR_WHITE, "[CMD]:/sethealth [PlayerID] [Amount]");
if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid ,COLOR_BRIGHTRED,"[ERROR]:Player not Found!");
GetPlayerName(playerid, aName, sizeof(aName));
GetPlayerName(pID, pName, sizeof(pName));
//format(string, sizeof(string),"Admin Has Healed You", aName, pName, Amount); //You can do this with SendClientMessage, aName, pName, Amount will be useless.
format(string, sizeof(string),"Admin %s Has Set %s's Health to %d", aName, pName, Amount); //Admin "playerid" has set "pID" Health to "Amount"
SendClientMessage(playerid, COLOR_BRIGHTRED, string); //Sends the message to playerid who uses the command
SendClientMessage(pID, COLOR_BRIGHTRED, string); //Sends the message to target playerid (aka pID)
SetPlayerHealth(pID, Amount); //Sets pID health to Amount
return 1;
}