Useful Commands #1
#21

-Bump-

I liked the topic, its a shame that people dont post any new cmd\'s, so I\'ll do .

Here\'s my working slap-command, if you want to use it you also need to paste the strtok function in your script. Also define the COLOR_PINK and COLOR_WHITE on top of your script.

Have fun .

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
  new adminname[256];
  new playername[256];
  new id;
    new tmp[256];
    new cmd[256];
    new Float:health, Float:x, Float:y, Float:z;
 
    new idx;
 
    cmd = strtok(cmdtext, idx);
    if(strcmp(cmd, "/slap", true) == 0 && IsPlayerAdmin(playerid)==1) {
 
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /slap <playerid>");
        return 1;
        }
        if(!IsPlayerAdmin(playerid))
        {
          SendClientMessage(playerid, COLOR_WHITE, "You haven\'t got any admin rights");
          return 1;
        }
        id = strval(tmp);
        if(IsPlayerConnected(id)) {
       
          GetPlayerPos(id, x, y, z);
          PlayerPlaySound(id, 1190, x, y, z);
            SetPlayerPos(id, x, y, z+2);
            GetPlayerHealth(id, health);
            SetPlayerHealth(id, health-10);
          GetPlayerName(id, playername, 256);
          GetPlayerName(playerid, adminname, 256);
 
            format(string, sizeof(string), "%s slaps %s with a large fish!! /*You can also add some other text here to your likings..*/", adminname, playername);
            SendClientMessageToAll(COLOR_PINK, string);
            /*format(string, sizeof(string), "%s slapped you!!", adminname);
            SendClientMessage(id, COLOR_WHITE, string);*/

        }
        else {
          format(string, sizeof(string), "%d is not an active player.", id);
          SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }
    return 0;
}
Reply
#22

Here is some commands i created for admins (for fun, and also to annoy cheaters before kicking/banning them!) I hope you like and please give credits if you use these cool commands :

First, add this at the begining of the script:
pawn Code:
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA


GOD MODE reset your life to 250hp each 50ms, you can fall of the hightest building without dying (if you have no parachute)

At the begining of the script:
pawn Code:
new GodTimer;
new God[MAX_PLAYERS];
In OnGameModeInit:
pawn Code:
GodTimer = SetTimer("InfiniteLife",50,1);
In OnGameModeExit:
pawn Code:
KillTimer(GodTimer);
The command:
pawn Code:
if((strcmp(cmdtext,"/iddad",true)==0)||(strcmp(cmdtext,"/god",true)==0))
  {
    if (IsPlayerAdmin(playerid))
    {
      if(God[playerid] == 0)
      {
        God[playerid] = 1;
        SendClientMessage(playerid,COLOR_GREEN,"GODMODE ON");
      }
      else
      {
        God[playerid] = 0;
        SendClientMessage(playerid,COLOR_RED,"GODMODE OFF");
        SetPlayerHealth(playerid, 100);
      }
    }
    else
    {
      SendClientMessage(playerid,COLOR_RED,"COMMANDS FOR ADMINS ONLY");
    }
    return 1;
  }
The function:
pawn Code:
public InfiniteLife()
{
  for (new i = 0; i < MAX_PLAYERS; i++)
  {
    if (IsPlayerConnected(i) && God[i] == 1)
    {
      SetPlayerHealth(i, 250);
    }
  }
}


RANDOM WEAPONS SET(thx to Simon) give you random set of weapons (you have to define the sets)

At the begining of the script:
pawn Code:
new Weapons[MAX_PLAYERS];
new WeaponSet[4][5] =
{
  {9, 24, 26, 32, 38},
  {8, 23, 25, 30, 37},
  {2, 10, 22, 28, 41},
  {5, 14, 23, 29, 42}
/* {x1, x2, x3, x4, x5},
  {x1, x2, x3, x4, x5},
  {x1, x2, x3, x4, x5},
  {x1, x2, x3, x4, x5},
  {x1, x2, x3, x4, x4} EACH "x" IS A WEAPON TO CHOOSE IN A CLASS. x1 is melee*/

};
The command:
pawn Code:
if((strcmp(cmdtext,"/idkfq",true)==0)||(strcmp(cmdtext,"/weapons",true)==0))
  {
    if (IsPlayerAdmin(playerid))
    {
      new setid = random(sizeof(WeaponSet));
      new ammos = 999999999;
      if (Weapons[playerid] == 0)
      {
        Weapons[playerid] = 1;
        GivePlayerWeapon(playerid,WeaponSet[setid][0],1);//MELEE: AMMO=1
        GivePlayerWeapon(playerid,WeaponSet[setid][1],ammos);
        GivePlayerWeapon(playerid,WeaponSet[setid][2],ammos);
        GivePlayerWeapon(playerid,WeaponSet[setid][3],ammos);
        GivePlayerWeapon(playerid,WeaponSet[setid][4],ammos);
        SendClientMessage(playerid,COLOR_GREEN,"WEAPONS ON");
      }
      else
      {
        Weapons[playerid] = 0;
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid,24,507);
        SendClientMessage(playerid,COLOR_RED,"WEAPONS OFF");
      }
    }
    else
    {
      SendClientMessage(playerid,COLOR_RED,"COMMANDS FOR ADMINS ONLY");
    }
    return 1;
  }


REGULAR MONEY give you 1000$ each 2 seconds

At the begining of the script:
pawn Code:
new GiveMoneyTimer;
new GiveMoney[MAX_PLAYERS];
In OnGameModeInit:
pawn Code:
GiveMoneyTimer = SetTimer("Money",2000,1);
In OnGameModeExit:
pawn Code:
KillTimer(GiveMoneyTimer);
The command:
pawn Code:
if(strcmp(cmdtext,"/cash",true)==0)
  {
    if (IsPlayerAdmin(playerid))
    {
      if (GiveMoney[playerid] == 0)
      {
        GiveMoney[playerid] = 1;
        SendClientMessage(playerid,COLOR_GREEN,"CASH ON");
      }
      else
      {
        GiveMoney[playerid] = 0;
        SendClientMessage(playerid,COLOR_RED,"CASH OFF");
      }
    }
    else
    {
      SendClientMessage(playerid,COLOR_RED,"COMMANDS FOR ADMINS ONLY");
    }
    return 1;
  }
The function:
pawn Code:
public Money()
{
  for (new i = 0; i < MAX_PLAYERS; i++)
  {
    if (IsPlayerConnected(i) && GiveMoney[i] == 1)
    {
      GivePlayerMoney(i,1000);
    }
  }
}

Retype these commands to turn off them, or use this reset command:

pawn Code:
if(strcmp(cmdtext,"/reset",true)==0)
  {
    if (IsPlayerAdmin(playerid))
    {
      if ((God[playerid] == 0)&&(Weapons[playerid] == 0)&&(GiveMoney[playerid] == 0))
      {
        SendClientMessage(playerid,COLOR_GREEN,"NOTHING TO RESET");
      }
      if (God[playerid] == 1)
      {
        God[playerid] = 0;
        SetPlayerHealth(playerid,100);
        SendClientMessage(playerid,COLOR_RED,"GODMODE OFF");
      }
      if (Weapons[playerid] == 1)
      {
        Weapons[playerid] = 0;
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid,24,507);
        SendClientMessage(playerid,COLOR_RED,"WEAPONS OFF");
      }
      if (GiveMoney[playerid] == 1)
      {
        GiveMoney[playerid] = 0;
        SendClientMessage(playerid,COLOR_RED,"CASH OFF");
      }
    }
    else
    {
      SendClientMessage(playerid,COLOR_RED,"COMMANDS FOR ADMINS ONLY");
    }
    return 1;
  }
Reply
#23

Logged as admin
pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0) {
  SendClientMessage(playerid, COLOR_YELLOW,"***You logged as admin");
  IsPlayerAdmin(playerid);
  return 1;
  }
Reply
#24

Quote:
Originally Posted by [EGG
Marco ]
Logged as admin
pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0) {
  SendClientMessage(playerid, COLOR_YELLOW,"***You logged as admin");
  IsPlayerAdmin(playerid);
  return 1;
  }
To me that just checks if your logged in as admin. I dont see a point..If I signed in as Admin I would kind of know it
Reply
#25

Ok, hi all ME is back with his stupid questions..
i hope you help me little bit i am a beginner in scripting..
so my problem is this:
http://pastebin.ca/180909
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(147) : warning 219: local variable "i" shadows a variable at a preceding level
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(179) : warning 219: local variable "i" shadows a variable at a preceding level
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(345) : error 029: invalid expression, assumed zero
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(345 -- 346) : warning 215: expression has no effect
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(346) : error 001: expected token: ";", but found "if"
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(34 : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(351) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(354) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(357) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(359) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(36 : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(372) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(374) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(376) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(379) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(382) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(384) : error 021: symbol already defined: "i"
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(385) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(393) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(397) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(401) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(411) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(413) : error 010: invalid function or declaration
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(480) : warning 203: symbol is never used: "f"
E:\Rockstar Games\GTA San Andreas\gamemodes\src\Thetest.pwn(480) : warning 203: symbol is never used: "i"
Pawn compiler 3.0.3367 Copyright © 1997-2005, ITB CompuPhase


20 Errors.


Sorry, if that error message was too long. Ban me then
Reply
#26

Me,

Is the topic subject is "Post here your Useless/Uninterresting Errors, Warnings!" ?

No, this is a "commands showroom", please post somewhere else .

For your problem, read the pawn documentation (pawn-lang.pdf) in your pawno folder, all errors are solved in.
Reply
#27

Quote:
Originally Posted by [EGG
Marco ]
Logged as admin
pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0) {
  SendClientMessage(playerid, COLOR_YELLOW,"***You logged as admin");
  IsPlayerAdmin(playerid);
  return 1;
  }
Maybe this...?
pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0 && IsPlayerAdmin(playerid) == true) {
  SendClientMessage(playerid, COLOR_YELLOW,"***You are logged as admin");
  return 1;
  }
if(strcmp(cmdtext, "/admincheg", true) == 0 && IsPlayerAdmin(playerid) == false) {
  SendClientMessage(playerid, COLOR_YELLOW,"***You are not logged as admin");
  return 1;
  }
Haven\'t tested it but that other thing was pointless that u made
Reply
#28

Why not simply:

pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0)
{
  if (IsPlayerAdmin(playerid) == true)
  {
    SendClientMessage(playerid, COLOR_YELLOW,"***You are logged as admin");
  }
  else
  {
    SendClientMessage(playerid, COLOR_YELLOW,"***You are not logged as admin");
  }
  return 1;
}
Reply
#29

Quote:
Originally Posted by yom
Why not simply:

pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0)
{
  if (IsPlayerAdmin(playerid) == true)
  {
    SendClientMessage(playerid, COLOR_YELLOW,"***You are logged as admin");
  }
  else
  {
    SendClientMessage(playerid, COLOR_YELLOW,"***You are not logged as admin");
  }
  return 1;
}
C:\DOCUME~1\User\0016~1\12345\SAMP01~1\GAMEMO~1\sr c\sftdm.pwn(1419) : warning 213: tag mismatch
Reply
#30


pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0)
{
  if (IsPlayerAdmin(playerid))
  {
    SendClientMessage(playerid, COLOR_YELLOW, "*** You are logged as admin");
  }
  else
  {
    SendClientMessage(playerid, COLOR_YELLOW, "*** You are not logged as admin");
  }
  return 1;
}
Reply
#31

[quote=sXd ]
Quote:
Originally Posted by yom
Why not simply:

pawn Code:
if(strcmp(cmdtext, "/admincheg", true) == 0)
{
  if (IsPlayerAdmin(playerid))
  {
    SendClientMessage(playerid, COLOR_YELLOW, "*** You are logged as admin");
  }
  else
  {
    SendClientMessage(playerid, COLOR_YELLOW, "*** You are not logged as admin");
  }
  return 1;
}
That works but I dont see the point...If your logged in as admin wouldnt you know when you typed /rcon login
Reply
#32

Stop repeating the same things over and over again
This topic is made for posting commands; of course tested
and working commands.
Reply
#33

Help Me

Code:
Code:
		if(strcmp(cmdtext,"/clearchat",true)==0) // Chat window is gone, fomg!
		{
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
            SendClientMessage(playerid,COLOR_GREY," ");
		return 1;
		}
Error:
Code:
C:\DOCUME~1\ROGER~1\MEUSDO~1\30C6CD~1.0FU\GAMEMO~1\src\drift.pwn(129) : error 010: invalid function or declaration
C:\DOCUME~1\ROGERK1\MEUSDO~1\30C6CD~1.0FU\GAMEMO~1\src\drift.pwn(141) : error 010: invalid function or declaration
Pawn compiler 3.0.3367			Copyright © 1997-2005, ITB CompuPhase


2 Errors.
Reply
#34

What you try to do is called "wiper", idea by Spectre (if i remember) :

pawn Code:
if(strcmp(cmdtext,"/clearchat",true)==0) // Chat window is gone, fomg!
{
  for (new a=1;a<=10;a++)
  {
    SendClientMessage(playerid,COLOR_GREY,"
"
);
  }
  return 1;
}
Reply
#35

Have

"return 1;"
Reply
#36

/\
||
||
"return 1;" have in the two lines of the error
Reply
#37

CHANGING LANGUAGE IN-GAME:

This allow you to change the language in-game by typing the shortcut of the language, can be really useful


At the begining of the script:

pawn Code:
new Language[MAX_PLAYERS] = 0; //initialyse with the default language = english
In OnPlayerConnect

pawn Code:
SendClientMessage(playerid,0xC0C0C0FF,"Please choose a language : /en - /fr - /de (default is EN)");
Languages commands:

pawn Code:
if(strcmp(cmdtext,"/en",true) == 0)
  {
    Language[playerid] = 0;
    SendClientMessage(playerid,0xC0C0C0FF,"You choose the english language.");
    return 1;
  }
   
  else if(strcmp(cmdtext,"/fr",true) == 0)
  {
    Language[playerid] = 1;
    SendClientMessage(playerid,0xC0C0C0FF,"Tu as choisis le langage francais.");
    return 1;
  }
   
  else if(strcmp(cmdtext,"/de",true) == 0)
  {
    Language[playerid] = 2;
    SendClientMessage(playerid,0xC0C0C0FF,"Du hast die deutsche Sprache gewдhlt.");
    return 1;
  }
Example command for the HELP:

pawn Code:
else if((strcmp(cmdtext,"/help",true) == 0)||
      (strcmp(cmdtext,"/aide",true) == 0)||
      (strcmp(cmdtext,"/hilfe",true) == 0))
  {
    switch (Language[playerid])
    {
      case 0:
      {
        SendClientMessage(playerid,0xFFD400AA,"HELP:");
        SendClientMessage(playerid,0xFFD400AA,"Type /lock to close your vehicle.");
        SendClientMessage(playerid,0xFFD400AA,"Type /unlock to open your vehicle.");
      }
      case 1:
      {
        SendClientMessage(playerid,0xFFD400AA,"AIDE:");
        SendClientMessage(playerid,0xFFD400AA,"Tape /lock pour fermer ton vehicule.");
        SendClientMessage(playerid,0xFFD400AA,"Tape /unlock pour ouvrir ton vehicule.");
      }
      case 2:
      {
        SendClientMessage(playerid,0xFFD400AA,"HILFE:");
        SendClientMessage(playerid,0xFFD400AA,"Tippt /lock, um dein vehicule zu schlieЯen.");
        SendClientMessage(playerid,0xFFD400AA,"Tippt /unlock, um dein vehicule zu erцffnen.");
      }
    }
    return 1;
  }

Easy no? Enjoy the multilanguage

Ps: sorry for the deutch traduction, i use a translator
Reply
#38

Nice code there Yom, tho that will be some LONG commands out there
Reply
#39

Well, i use this one in mabako\'s admin script, combined with the GetHelp function (read messages from language files), so i need only one check in the GetHelp function, then it read in the good language file once i have typed /fr , or /en...at the moment if i type /de it read the default file (english) because i can\'t traduce all in deutch .
Reply
#40

Nice coding! Just for the record, it is German (/de ) and not Dutch (which is /nl) . If you need a translation to Dutch, I can give you a hand.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)