/explode buggs.
#1

Hello,

I have created a command with me friend, but it dont works on another player,
I type /explode 1 ( 0 = my id ) and then get i a explode.. >.<

Sorry for bad English >.<

Quote:

Here is the script.

if(strcmp(cmd, "/explode", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "Use: /explode [PlayerID/PlayerNickName]");
return 1;
}
new playa;
new Float,Float:y,Float:z;
if(IsPlayerAdmin(playerid))
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerPos(playa, x, y, z);
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 104)
printf("AdmCmd: %s exploded %s",sendername, giveplayer);
format(string, sizeof(string), "AdmCmd: %s was been Exploded by %s",giveplayer ,sendername);
SendClientMessageToAll(COLOR_RED, string);
CreateExplosion(x, y, z, 10, 30);
CreateExplosion(x + 1, y, z, 10, 30);
CreateExplosion(x + 1, y + 1, z, 10, 30);
CreateExplosion(x, y + 1, z, 10, 30);
CreateExplosion(x - 1, y, z, 10, 30);
CreateExplosion(x, y - 1, z, 10, 30);
CreateExplosion(x - 1, y - 1, z, 10, 30);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "The player is off!");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You don't are Admin!");
return 1;
}
}
SendClientMessage(playerid, COLOR_GREY, "The Player is off!");
return 1;
}

Reply
#2

pawn Код:
if(strcmp(cmd, "/explode", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "Use: /explode [PlayerID/PlayerNickName]");
                return 1;
            }
            new playa = ReturnUser(tmp);//you need this which i'll incude below.
            new Float:x,Float:y,Float:z;
            if(IsPlayerAdmin(playerid))
            {
              if(IsPlayerConnected(playa))
              {
                if(playa != INVALID_PLAYER_ID)
                {
                    GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                  GetPlayerPos(playa, x, y, z);
                  if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 104)
                  printf("AdmCmd: %s exploded %s",sendername, giveplayer);
                        format(string, sizeof(string), "AdmCmd: %s was been Exploded by %s",giveplayer ,sendername);
                        SendClientMessageToAll(COLOR_RED, string);
                  CreateExplosion(x, y, z, 10, 30);
                  CreateExplosion(x + 1, y, z, 10, 30);
                  CreateExplosion(x + 1, y + 1, z, 10, 30);
                  CreateExplosion(x, y + 1, z, 10, 30);
                  CreateExplosion(x - 1, y, z, 10, 30);
                  CreateExplosion(x, y - 1, z, 10, 30);
                  CreateExplosion(x - 1, y - 1, z, 10, 30);
                  return 1;
                    }
                    else
                    {
                    SendClientMessage(playerid, COLOR_GREY, "The player is off!");
                    return 1;
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You don't are Admin!");
                return 1;
            }
        }
        SendClientMessage(playerid, COLOR_GREY, "The Player is off!");
        return 1;
    }
pawn Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21) // Strip out leading spaces
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos])) // Check whole passed string
    {
        // If they have a numeric name you have a problem (although names are checked on id failure)
        userid = strval(text[pos]);
        if (userid >=0 && userid < SLOTS)
        {
            if(!IsPlayerConnected(userid))
            {
                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid; // A player was found
            }
        }
    }
    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < SLOTS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
            {
                if (len == strlen(name)) // Exact match
                {
                    return i; // Return the exact player on an exact match
                    // Otherwise if there are two players:
                    // Me and MeYou any time you entered Me it would find both
                    // And never be able to return just Me's id
                }
                else // Partial match
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid; // INVALID_USER_ID for bad return
}
Reply
#3

Thnxs, but can you give me a link for the include, i cant find it.
Reply
#4

tmp = strtok(cmdtext, idx);
edited to
new playa = strtok(cmdtext, idx);
thqn fix any error which cause by this editing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)