/slap rcon command
#1

has any1 got a /slap command (rcon only"i can add that bit)


because every /slap i make it only lets me slap my self >_<


thanks
Reply
#2

bump any 1?
Reply
#3

I use this one:
pawn Код:
dcmd_drill(playerid,params[])
{
   new tmp[100],Index,Float:health;
   new damage;
   new id = strval(params);
   new string[128];
   tmp = strtok(params,Index);
   GetPlayerHealth(id,health);
   if(sscanf(params, "ud", id, damage)) return SendClientMessage(playerid,color,""#red"USAGE: "#green"/drill <id> <damage>");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid,color,""#red"This player "#green"isn't connected");
   SetPlayerHealth(id,health-damage);
   for(new v; v < MAX_PLAYERS; v++) PlayerPlaySound(v,1133,0.0,0.0,0.0);
   format(string,sizeof(string),""#red"[ADMIN]: "#ice"%s (id: %d) has drilled "#green"%s (id: %d) [Damage taken: %d | Health left: %d]",GetMyName(playerid),playerid,GetMyName(id),id,floatround(damage),floatround(health-damage));
   return SendClientMessageForAll(color,string);
}

It's as same as slap one, just the name that's different. Do the needed changes, since it was on my script
Reply
#4

pawn Код:
if(strcmp(cmd, "/slap", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_FAILRED, "/slap [playerid]");
                return 1;
            }
            new giveplayerid;
            giveplayerid = ReturnUser(tmp);
            new Float:x, Float:y, Float:z;
            if (IsPlayerAdmin(playerid))
            {
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(giveplayerid, x, y, z);
                        SafeSetPlayerPos(giveplayerid, x, y, z+5);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "Invalid ID!");
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your not authorised to use this command.);
            }
        }
        return 1;
    }
Reply
#5

Quote:
Originally Posted by Mokerr
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/slap", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_FAILRED, "/slap [playerid]");
                return 1;
            }
            new giveplayerid;
            giveplayerid = ReturnUser(tmp);
            new Float:x, Float:y, Float:z;
            if (IsPlayerAdmin(playerid))
            {
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(giveplayerid, x, y, z);
                        SafeSetPlayerPos(giveplayerid, x, y, z+5);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "Invalid ID!");
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your not authorised to use this command.);
            }
        }
        return 1;
    }
got errors

Код:
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(583) : error 017: undefined symbol "tmp"
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(584) : error 017: undefined symbol "tmp"
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(590) : error 017: undefined symbol "ReturnUser"
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(609) : error 037: invalid string (possibly non-terminated string)
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(609) : error 017: undefined symbol "Your"
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(609) : error 017: undefined symbol "not"
C:\Users\Stephen-Laptop\Desktop\server samp - Copy\filterscripts\adminscript.pwn(609) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
Reply
#6

I really suggest you switch to ZCMD for faster and more efficient command processing.

The following code is untested:
pawn Код:
if( !strcmp( cmdtext, "/slap", true ) )
{
   if( !cmdtext[ 5 ] ) return 0; // No parameters entered
   if( !IsPlayerConnected( strval( cmdtext[ 6 ] ) ) ) return 0; // target not connected
   new Float: Pos[ 3 ];
   GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   SetPlayerPos( strval( cmdtext[ 6 ] ), Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   return 1;
}
Obviously, this is the base of the command. Adjust as necessary.
Reply
#7

Quote:
Originally Posted by Grim_
Посмотреть сообщение
I really suggest you switch to ZCMD for faster and more efficient command processing.

The following code is untested:
pawn Код:
if( !strcmp( cmdtext, "/slap", true ) )
{
   if( !cmdtext[ 5 ] ) return 0; // No parameters entered
   if( !IsPlayerConnected( strval( cmdtext[ 6 ] ) ) ) return 0; // target not connected
   new Float: Pos[ 3 ];
   GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   SetPlayerPos( strval( cmdtext[ 6 ] ), Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
   return 1;
}
Obviously, this is the base of the command. Adjust as necessary.
i hate zcmd i prefer the oldschool stuff dont worry thanks anyway
Reply
#8

I don't see why people dislike ZCMD, it's an amazing command processor which makes this much quicker and way more efficient! Oh well... people have their own opinions I suppose. You should switch though...
Reply
#9

pawn Код:
if(strcmp(cmd, "/slap", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
                        new tmp;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_FAILRED, "/slap [playerid]");
                return 1;
            }
            new giveplayerid;
            giveplayerid = ReturnUser(tmp);
            new Float:x, Float:y, Float:z;
            if (IsPlayerAdmin(playerid))
            {
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(giveplayerid, x, y, z);
                        SafeSetPlayerPos(giveplayerid, x, y, z+5);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "Invalid ID!");
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Your not authorised to use this command.");
            }
        }
        return 1;
    }
and put this in your script:
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 < MAX_PLAYERS)
        {
            if(!IsPlayerConnected(userid))
            {
                /*if (playerid != INVALID_PLAYER_ID)
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }*/

                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid; // A player was found
            }
        }
        /*else
        {
            if (playerid != INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
            }
            userid = INVALID_PLAYER_ID;
        }
        return userid;*/

        // Removed for fallthrough code
    }
    // They entered [part of] a name or the id search failed (check names just incase)
    new len = strlen(text[pos]);
    new count = 0;
    new name[MAX_PLAYER_NAME];
    for (new i = 0; i < MAX_PLAYERS; 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
#10

@ RealCop

I honestly think people hate ZCMD because they have never tried or used it. Half the people i ask if they like or hate it they auto say "hate it" no matter what. Then i asked if they ever used it and about more than half of them said no, since it's "too complicated" to be honest, it's the fastest/best command processor and it is very simple to use. Way more simple than DCMD. But you all can think what you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)