Jump to content
  • 0

pomoc [Help]Prikaz Id Duvod


HomerSimpsons:D

Dotaz

cs mam problem nevim jak udelat abych dal prikaz /oznameni ID DUVOD mam to jen na prikaz a id ale nevim jak dat ten duvod zde je kod

dcmd_oznameni(playerid,params[])
{
new ID = strval(params);
if(!strlen(params))return SendClientMessage(playerid,0xFFFFFFFF,"Zapoměl jsi napsat ID toho parchanta:D");
if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0xFFFFFFFF,"[ ! ] Ten parchant není připojený!");//Pokud hráč se zadaným ID není na serveru
new string[256];
format(string, sizeof(string), "Hráč %s podáva trestné oznámení na hráče %s za porušení pravidel", PlayerName(playerid), PlayerName(ID));
SendClientMessageToAll(0xFF9900AA, string);
return 1;
}

dekuji za rady

Link to comment
Share on other sites

8 odpovědí na tuto otázku

Recommended Posts

  • 0

dcmd_oznameni(playerid, params[])
{
new string[128],ID,duvod;
if(sscanf(params,"iz",ID,duvod)) return SendClientMessage(playerid,-1,"Použití: /oznameni [iD] [DŮVOD]");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,-1,"Hráč není připojen!");
format(string,sizeof(string),"Hráč %s podává trestné oznámení na hráče %s za porušní pravidel",PlayerName(playerid),PlayerName(ID));
SendClientMessageToAll(-1,string);
return 1;
}

 

 

A tady máš stock sscnaf pokud ho nemáš dej ho dolů:

 

stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
 if (isnull(string))
#else
 if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
 {
  return format[0];
 }
#pragma tabsize 4
new
 formatPos = 0,
 stringPos = 0,
 paramPos = 2,
 paramCount = numargs(),
 delim = ' ';
while (string[stringPos] && string[stringPos] <= ' ')
{
 stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
 switch (format[formatPos++])
 {
  case '\0':
  {
return 0;
  }
  case 'i', 'd':
  {
new
 neg = 1,
 num = 0,
 ch = string[stringPos];
if (ch == '-')
{
 neg = -1;
 ch = string[++stringPos];
}
do
{
 stringPos++;
 if ('0' <= ch <= '9')
 {
  num = (num * 10) + (ch - '0');
 }
 else
 {
  return -1;
 }
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num * neg);
  }
  case 'h', 'x':
  {
new
 num = 0,
 ch = string[stringPos];
do
{
 stringPos++;
 switch (ch)
 {
  case 'x', 'X':
  {
   num = 0;
   continue;
  }
  case '0' .. '9':
  {
   num = (num << 4) | (ch - '0');
  }
  case 'a' .. 'f':
  {
   num = (num << 4) | (ch - ('a' - 10));
  }
  case 'A' .. 'F':
  {
   num = (num << 4) | (ch - ('A' - 10));
  }
  default:
  {
   return -1;
  }
 }
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num);
  }
  case 'c':
  {
setarg(paramPos, 0, string[stringPos++]);
  }
  case 'f':
  {
new changestr[16], changepos = 0, strpos = stringPos;
while(changepos < 16 && string[strpos] && string[strpos] != delim)
{
 changestr[changepos++] = string[strpos++];
   	}
changestr[changepos] = '\0';
setarg(paramPos,0,_:floatstr(changestr));
  }
  case 'p':
  {
delim = format[formatPos++];
continue;
  }
  case '\'':
  {
new
 end = formatPos - 1,
 ch;
while ((ch = format[++end]) && ch != '\'') {}
if (!ch)
{
 return -1;
}
format[end] = '\0';
if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
{
 if (format[end + 1])
 {
  return -1;
 }
 return 0;
}
format[end] = '\'';
stringPos = ch + (end - formatPos);
formatPos = end + 1;
  }
  case 'u':
  {
new
 end = stringPos - 1,
 id = 0,
 bool:num = true,
 ch;
while ((ch = string[++end]) && ch != delim)
{
 if (num)
 {
  if ('0' <= ch <= '9')
  {
   id = (id * 10) + (ch - '0');
  }
  else
  {
   num = false;
  }
 }
}
if (num && IsPlayerConnected(id))
{
 setarg(paramPos, 0, id);
}
else
{
 #if !defined foreach
  #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  #define __SSCANF_FOREACH__
 #endif
 string[end] = '\0';
 num = false;
 new
  name[MAX_PLAYER_NAME];
 id = end - stringPos;
 foreach (Player, playerid)
 {
  GetPlayerName(playerid, name, sizeof (name));
  if (!strcmp(name, string[stringPos], true, id))
  {
   setarg(paramPos, 0, playerid);
   num = true;
   break;
  }
 }
 if (!num)
 {
  setarg(paramPos, 0, INVALID_PLAYER_ID);
 }
 string[end] = ch;
 #if defined __SSCANF_FOREACH__
  #undef foreach
  #undef __SSCANF_FOREACH__
 #endif
}
stringPos = end;
  }
  case 's', 'z':
  {
new
 i = 0,
 ch;
if (format[formatPos])
{
 while ((ch = string[stringPos++]) && ch != delim)
 {
  setarg(paramPos, i++, ch);
 }
 if (!i)
 {
  return -1;
 }
}
else
{
 while ((ch = string[stringPos++]))
 {
  setarg(paramPos, i++, ch);
 }
}
stringPos--;
setarg(paramPos, i, '\0');
  }
  default:
  {
continue;
  }
 }
 while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
 {
  stringPos++;
 }
 while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
 {
  stringPos++;
 }
 paramPos++;
}
do
{
 if ((delim = format[formatPos++]) > ' ')
 {
  if (delim == '\'')
  {
while ((delim = format[formatPos++]) && delim != '\'') {}
  }
  else if (delim != 'z')
  {
return delim;
  }
 }
}
while (delim > ' ');
return 0;
}

Link to comment
Share on other sites

  • 0

dcmd_oznameni(playerid,params[])

{

new ID = strval(params), duvod = chrfind(' ',params)+1;

if(!params[0] || duvod == 0)return SendClientMessage(playerid,0xFFFFFFFF," /Oznameni id duvod");

if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0xFFFFFFFF,"[ ! ] Ten parchant není připojený!");//Pokud hráč se zadaným ID není na serveru

new string[256];

format(string, sizeof(string), "Hráč %s podáva trestné oznámení na hráče %s za %s", PlayerName(playerid), PlayerName(ID),duvod);

SendClientMessageToAll(0xFF9900AA, string);

return 1;

}

// Zkus snad ti to bude funkvat :) nezkousel jsem to

Link to comment
Share on other sites

  • 0

prave to tvoje mi to dela a to drhy pise tento error:error 017: undefined symbol "chrfind" sice vim ze to je ze tam ten symbol neni ale kam ho mam napsat?

 

dcmd_oznameni(playerid, params[])
{
 new ID = strval(params);
 if(IsPlayerConnected(playerid))
 {
 if(!strlen(params)) return SendClientMessage(playerid,0xFFFFFFFF, "Použiti /oznameni [id] [dôvod]."); // Správne použitie
 if(!IsPlayerConnected(ID)) return SCM(playerid, 0xFFFFFFFF,"Hrac neni na serveru !!"); // Ak hráč z tým id nie je pripojený
 new string[156];
 format(string, sizeof(string), "Hráč %s podáva trestné oznámení na hráče %s [Duvod : %s] ",PlayerName(ID), PlayerName(playerid),params); // Správa
 SendClientMessageToAll(0xFF9900AA, string);
 }
 return true;
}

tady mi to do duvodu hodi i id:(

 

Hráč homer podáva trestné oznámení na hráče homer [Duvod : 0 test]

Link to comment
Share on other sites

  • 0

Kel máš to zle pretože ti to len vypíše správu ak nenapíšeš id a dôvod

 

 

dcmd_oznameni(playerid, params[])

{

new string[128],ID,duvod;

if(sscanf(params,"iz",ID,duvod)) return SendClientMessage(playerid,-1,"Použití: /oznameni [iD] [DŮVOD]");

else

{

if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,-1,"Hráč není připojen!");

format(string,sizeof(string),"Hráč %s podává trestné oznámení na hráče %s za porušní pravidel",PlayerName(playerid),PlayerName(ID));

SendClientMessageToAll(-1,string);

}

return 1;

}

takto je to správne

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...