Help..How to??
#1

Hello..i am new in scripting and i have a problem

How to make example a new category(if you know on what i am meaning)

Ex:

public OnGameModeInit()

...Can i make example

public D_commands()

??
Reply
#2

you got some public you can do public D_commands

you can use some i know some like


public OnGameModeInit
public OnPlayerCommandText
public OnDialogResponse
public ShowPlayerDialog
public OnPlayerDeaths
public OnPlayerConnect
public OnPlayerDisconnect
.
.
.
and more you can find it in a_samp.inc inside include files
Reply
#3

Can example do

public Command(playerid, cmdtext[])
{
if (strcmp(cmd, "/drugtest", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (IsACop(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "KORISTI: /drugtest [playerid/Dio Imena]");
return 1;
}
giveplayerid = ReturnUser(tmp);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(GetDistanceBetweenPlayers(playerid,giveplayerid ) < 3)
{
if(PlayerStoned[playerid] >= 1)
{
format(string, sizeof(string), "* %s je dao test na drogu igracu,a %s ga je stavio u usta.", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "** Test na dorgu: Nadrogiran **");
GameTextForPlayer(playerid,"~w~Ovaj igrac je~n~~r~nadrogiran", 8000, 1);
return 1;
}
else
{
format(string, sizeof(string), "* %s je dao test na drogu igracu,a %s ga je stavio u usta.", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "** Test na dorgu: Nije Nadrogiran **");
GameTextForPlayer(playerid,"~w~Ovaj igrac~n~~r~nije nadrogiran", 8000, 1);
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Igrac je offline !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Nisi ovlasten koristiti ovu komandu! (Cops Only)");
}
}
return 1;
}
or just

public Command() //without playerid and cmdtext[]
?
Reply
#4

you must do like this


public OnPlayerCommandText(playerid, cmdtext)
Reply
#5

pawn Код:
public OnPlayerCommandTexr(playerid, cmdtext[])
{
  new cmd[256];
  new idx;
  cmd = strtok(cmdtext,idx);
  if (strcmp(cmd, "/drugtest", true) == 0)
  {
    if(IsPlayerConnected(playerid))
    {
      if (IsACop(playerid))
      {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
          SendClientMessage(playerid, COLOR_GRAD1, "KORISTI: /drugtest [playerid/Dio Imena]");
          return 1;
        }
        giveplayerid = ReturnUser(tmp);
       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
       if(IsPlayerConnected(giveplayerid))
      {
        if(giveplayerid != INVALID_PLAYER_ID)
        {
          if(GetDistanceBetweenPlayers(playerid,giveplayerid ) < 3)
          {
            if(PlayerStoned[playerid] >= 1)
            {
              format(string, sizeof(string), "* %s je dao test na drogu igracu,a %s ga je stavio u usta.", sendername ,giveplayer);
              ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "** Test na dorgu: Nadrogiran **");
              GameTextForPlayer(playerid,"~w~Ovaj igrac je~n~~r~nadrogiran", 8000, 1);
              return 1;
            }
            else
            {
              format(string, sizeof(string), "* %s je dao test na drogu igracu,a %s ga je stavio u usta.", sendername ,giveplayer);
              ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
              SendClientMessage(playerid, COLOR_LIGHTBLUE, "** Test na dorgu: Nije Nadrogiran **");
              GameTextForPlayer(playerid,"~w~Ovaj igrac~n~~r~nije nadrogiran", 8000, 1);
              return 1;
            }
          }
        }
      }
      else
      {
        SendClientMessage(playerid, COLOR_GRAD1, " Igrac je offline !");
      }
    }
    else
    {
      SendClientMessage(playerid, COLOR_GRAD1, " Nisi ovlasten koristiti ovu komandu! (Cops Only)");
    }
  }
  return 1;
}
Reply
#6

if you want to change the name of a callback (public function) just define this:
pawn Код:
#define NewName CurrentName
for example:
pawn Код:
#define Command OnPlayerCommandText
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)