slap command -
Felipee - 28.11.2013
Hello,
Can someone help me with /slap command?
I want to add when you slap player you need to type in a reason why...
example; Mark_Wilson has been slapped by Admin,
reason: mg
Im using
GTARP mod.
Код:
//-----------------------------------[Slap]-----------------------------------------------
if(strcmp(cmd, "/slap", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "KORISCENJE: /slap [ID Igraca/Dio Imena]");
return 1;
}
new playa;
new Float:shealth;
new Float:slx, Float:sly, Float:slz;
playa = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >=1)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerHealth(playa, shealth);
SetPlayerHealth(playa, shealth-5);
GetPlayerPos(playa, slx, sly, slz);
SetPlayerPos(playa, slx, sly, slz+5);
PlayerPlaySound(playa, 1130, slx, sly, slz+5);
printf("[SLAP] %s je osamaren od strane Admina.",sendername, giveplayer );
format(string, sizeof(string), "[SLAP] %s je osamaren od strane Admina ",giveplayer ,sendername );
BroadCast(COLOR_LIGHTRED,string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Nemate pristup ovoj komandi!");
}
}
return 1;
}
Re: slap command -
Felipee - 30.11.2013
bump
Re: slap command -
xVIP3Rx - 30.11.2013
I'm not mature with commands OnPlayerCommandText, So I used
Zcmd and
sscanf, Here you go
pawn Код:
CMD:slap(playerid, params[])
{
  new id, reason[30];
  if(sscanf(params, "is[30]", id, reason)) return SendClientMessage(playerid, -1, "Usage: /Slap [id] [reason]");
  if(strlen(reason) < 1 || strlen(reason) > 30) return SendClientMessage(playerid, -1, "reason length must be between 1 - 30 characters");
  if (PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GRAD1, "Your level isn't high enough to use this command");
  if(!IsPlayerConnected(id) || id != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, "Nemate pristup ovoj komandi!");
  new Name[2][MAX_PLAYER_NAME],
    Float:H,
    Float:Pos[3],
    string[128];
   Â
  GetPlayerName(playerid, Name[0], MAX_PLAYER_NAME);
  GetPlayerName(id, Name[1], MAX_PLAYER_NAME);
 Â
  GetPlayerHealth(id, H);
  SetPlayerHealth(id, H-5);
 Â
  GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
  SetPlayerPos(id, Pos[0], Pos[1], Pos[2]+5);
  PlayerPlaySound(id, 1130, Pos[0], Pos[1], Pos[2]+5);
  printf("[SLAP] %s je osamaren od strane Admina.",Name[0], Name[1]);
  format(string, sizeof(string), "[SLAP] %s je osamaren od strane Admina ",Name[1], Name[0]);
  BroadCast(COLOR_LIGHTRED,string);
  return 1;
}
Re: slap command -
ReApZ - 30.11.2013
My Version
pawn Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][AdminLevel] >= 2)
  {
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /slap [playerid]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    SetPlayerPos(targetid, x, y, z+10);
    PlaySound(targetid, 1190);
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(targetid, name, sizeof(name));
    format(string, sizeof(string), "you have slapped %s", name);
    SendClientMessage(playerid, PLAYERCOLOR_AQUA, string);
    SendCommandToAdmins(playerid,"/slap");
  }
  else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 3 to start a HnS Event");
  return 1;
}
Re: slap command -
newbie scripter - 30.11.2013
Use [pawn] tag, the occupy less space...