SA-MP Forums Archive
Slap - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Slap (/showthread.php?tid=605763)



Slap - SaiyanZ - 24.04.2016

Hello,
Is there any way that i make a command, And the players near me get pushed back or just simply get slapped?



Re: Slap - J0sh... - 24.04.2016

Do a loop.
Get your own position.
Check if people in the loop is within the distance.
Slap them.


Re: Slap - oMa37 - 24.04.2016

Not sure if it works, i just made it :P:

PHP код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
    for(new 
i = 0; i < MAX_PLAYERS; i++)
    {
        if(!
IsPlayerConnected(i)) continue;
        {
            if(
IsPlayerInRangeOfPoint(i, 5.0, x, y, z))
            {
                
SetPlayerPos(i, x, y, z+3);
                
SendClientMessage(i, 0xFF000FF, "blablabla");
            }
            return 
1;
        }
        return 
1;
    } 



Re: Slap - SaiyanZ - 24.04.2016

Is this right?
No error but it says CMD_NSlap should return a value, If i try then it says unknown command, Maybe something wrong in it?
PHP код:
CMD:NSlap(playerid, params[])
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,x,y,z);
    for(new 
i = 0; i < MAX_PLAYERS; i++)
    {
        if(!
IsPlayerConnected(i)) continue;
        {
            if(
IsPlayerInRangeOfPoint(i, 5.0, x, y, z))
            {
                
SetPlayerPos(i, x, y, z+3);
                
SendClientMessage(i, 0xFF000FF, "!Tested!");
          }
        return 
1;
      }
    return 
1;
    }
} 



Re: Slap - J0sh... - 24.04.2016

PHP код:
CMD:NSlap(playerid, params[])
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,x,y,z);
    for(new 
i = 0; i < MAX_PLAYERS; i++)
    {
        if(!
IsPlayerConnected(i)) continue;
        {
            if(
IsPlayerInRangeOfPoint(i, 5.0, x, y, z))
            {
                
SetPlayerPos(i, x, y, z+3);
                
SendClientMessage(i, 0xFF000FF, "!Tested!");
            }
       }
    }
    return 
1;
} 



Re: Slap - SaiyanZ - 24.04.2016

Unknown Command.


Re: Slap - SaiyanZ - 25.04.2016

It slaps me instead of others, Anything wrong?


Re: Slap - oMa37 - 25.04.2016

Try this out:
PHP код:
CMD:slap(playerid, params[]) 
{ 
    new 
Float:x,Float:y,Float:z;
    new 
id;
    
GetPlayerPos(playerid,x,y,z); 
    if(
sscanf(params, "u", id))
    { 
        if(!
IsPlayerConnected(id))
        { 
            if(
IsPlayerInRangeOfPoint(id, 5.0, x, y, z)) 
            { 
                
SetPlayerPos(id, x, y, z+3); 
            } 
       } 
    }
    return 
1; 
} 



Re: Slap - nezo2001 - 25.04.2016

PHP код:
CMD:NSlap(playerid, params[]) 
{ 
    new 
Float:x,Float:y,Float:z; 
    
GetPlayerPos(playerid,x,y,z); 
    for(new 
i = 0; i < MAX_PLAYERS; i++) 
    { 
        if(!
IsPlayerConnected(i)) continue; 
        { 
            if(
IsPlayerInRangeOfPoint(i, 5.0, x, y, z) && i != playerid) 
            { 
                
SetPlayerPos(i, x, y, z+3); 
                
SendClientMessage(i, 0xFF000FF, "!Tested!"); 
            } 
       } 
    } 
    return 
1; 
}