/up command
#1

Hi all! I wanna to make a command for admins which will throw a player on some height. This will detect health hacks. But there is a problem
Код:
C:\DOCUME~1\86A9~1\0016~1\ladmin4.pwn(2841) : error 033: array must be indexed (variable "tmp2")
Full code of command.

Код:
dcmd_up(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid)) {
		  new tmp[256], tmp2[256], tmp3[256], Index;	tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
		  if(!strlen(params)) return SendClientMessage(playerid, red, " ПРАВКА: /up [playerid ] [height] [reason]");
	  	new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
				GetPlayerName(player1, playername, sizeof(playername));		GetPlayerName(playerid, adminname, sizeof(adminname));
				CMDMessageToAdmins(playerid,"/up");
		    new Float:x, Float:y, Float:z;
				GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+tmp2); PlayerPlaySound(playerid,1190,0.0,0.0,0.0); PlayerPlaySound(player1,1190,0.0,0.0,0.0);

				if(strlen(tmp3)) {
					format(string,sizeof(string)," Вас подкинул админ %s [причина: %s]",adminname,params[3]);	SendClientMessage(player1,COLOR_RED,string);
					format(string,sizeof(string)," Вы подкинули игрока %s [причина: %s]",playername,params[3]); return SendClientMessage(playerid,COLOR_RED,string);
				} else {
					format(string,sizeof(string)," Вас подкинул админ %s ",adminname);	SendClientMessage(player1,COLOR_RED,string);
					format(string,sizeof(string)," Вы подкинули игрока %s ",playername); return SendClientMessage(playerid,COLOR_RED,string); }
			} else return SendClientMessage(playerid, red, " Нет такого игрока");
		} else return SendClientMessage(playerid,red," ОШИБКА: У вас должен быть 2 уровень чтобы использовать эту команду");
	} else return SendClientMessage(playerid,red," ОШИБКА: Вы должны залогиниться");
}
And line 2841:

Код:
GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+tmp2); PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
Could anybody help?
Reply
#2

where is tmp2 is used?
Reply
#3

On the line 2841. This is the height.
Reply
#4

Where's the line on the given code?..
Reply
#5

Line 2841:

Код:
GetPlayerPos(player1,x,y,z); SetPlayerPos(player1,x,y,z+tmp2); PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
Reply
#6

You use so many wasted arrays there. My suggestion is to redo the code.
Reply
#7

So, you cant help with that simple error? I know for you it is simple but not for me.
Reply
#8

pawn Код:
dcmd_up(playerid,params[])
{
  if(PlayerInfo[playerid][LoggedIn]!=1) return SendClientMessage(playerid,red,"You must be logged.");
  if(PlayerInfo[playerid][Level]<2 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"You're not an admin.");
  new
    tmp[128],
    idx,
    adminame[MAX_PLAYER_NAME],
    PlayerName[MAX_PLAYER_NAME],
    Float:x,
    Float:y,
    Float:z;
  tmp=strtok(cmdtext,idx);
  if(!strlen(tmp)) return SendClientmessage(playerid,red,"USAGE: /up [playerid]");
  if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid,red,"Not connected.");
  GetPlayerName(strval(tmp),PlayerName,sizeof(PlayerName));
  GetPlayerName(playerid,adminname,sizeof(adminname);
  CMDMessageToAdmins(playerid,"/up");
  GetPlayerPos(strval(tmp),x,y,z);
  SetPlayerPos(strval(tmp),x,y,z+5);
  PlayerPlaySound(strval(tmp),1190,0.0,0.0,0.0);
  PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
  return 1;
}
Reply
#9

Thanks. But that I can make myself. I want admin will set the height on which the player will be thrown, not always z+5, but kind of z+tmp2.
Reply
#10

pawn Код:
if(strcmp(cmd, "/up", true) == 0){
          if(IsPlayerAdmin(playerid){
                new tmp[128],height;
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))return SendClientMessage(playerid, color, "USE: /up [playerid] [height]");
                giveplayerid = strval(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))return SendClientMessage(playerid, color, "USE: /up [playerid] [height]");
                height = strval(tmp);
                if(!IsPlayerConnected(giveplayerid))return SendClientMessage(playerid, color,"Bad Playerid");
                new Float:x,Float:y,Float:z;
                GetPlayerPos(giveplayerid,x,y,z);
                SetPlayerPos(giveplayerid,x,y,z+height);
            }else{
              SendClientMessage(playerid, color,"ERROR: ADMIN_ACCESS_REQUIERED");
            }
            return 1;
        }
this should help u.. if u cannot edit it for u'r need then sry man i'm not gonna help total n00bs.(if u got it and u have problems.. cuz this is untested .. then just ask me for help i look what I'd wrong.)

here u have a more "advanced" and tested one:
pawn Код:
if(strcmp(cmd, "/upingp", true)==0 && IsPlayerAdmin(playerid)) {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, color, "USE: /upingp [playerid] [height 1 - 20000]");
        }else{
            if(!IsPlayerConnected(strval(tmp))) {
                SendClientMessage(playerid, color, "Bad Playerid");
            } else {
                new newz;
                static Float:X;
                static Float:Y;
                static Float:Z;
                new VehicleID;
                tmp2 = strtok(cmdtext, idx);
                newz = strval(tmp2);
                if(!newz) {
                    SendClientMessage(playerid, color, "USE: /upingp [playerid] [height 1 - 20000]");
                    return 1;
                }
                if(newz >20000 || newz <1) {
                    SendClientMessage(playerid, color, "USE: /upingp [playerid] [height 1 - 20000]");
                }else {
                    if(IsPlayerInAnyVehicle(strval(tmp))) {
                        SetPlayerInterior(strval(tmp), 0);
                        GetPlayerPos(strval(tmp), X, Y, Z);
                        new inte;
                        inte = GetPlayerInterior(strval(tmp));
                        SetPlayerInterior(strval(tmp), inte);
                        VehicleID = GetPlayerVehicleID(strval(tmp));
                        SetVehiclePos(VehicleID,X,Y, Z+newz);
                    } else {
                        new inte;
                        inte = GetPlayerInterior(strval(tmp));
                        SetPlayerInterior(strval(tmp), inte);
                        GetPlayerPos(strval(tmp),X, Y,Z);
                        SetPlayerPos(strval(tmp),X,Y,Z+newz);
                    }
                }
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)