SA-MP Forums Archive
How to 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: How to slap ? (/showthread.php?tid=582418)



How to slap ? - Glossy42O - 20.07.2015

I tried to search around, i didn't find tutorials but

i found huge codes which idk what the slap does anyways

I don't want ALL the slap command, i want to know how to make the player being slapped that's it.


Re: How to slap ? - Beckett - 20.07.2015

What you do is get his coordinates (x,y,z) then increment the Z coordinate of how higher you want him to get slapped.

pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z+IncrementHere);



Re: How to slap ? - SoFahim - 20.07.2015

PHP код:
CMD:slap(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
string[128], giveplayerid;
        if(
sscanf(params"i"giveplayerid)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /slap [playerid]");
        new 
Float:shealth;
        new 
Float:slxFloat:slyFloat:slz;
        if(
IsPlayerConnected(giveplayerid))
        {
            
GetPlayerHealth(giveplayeridshealth);
            
SetPlayerHealth(giveplayeridshealth-5);
            
GetPlayerPos(giveplayeridslxslyslz);
            
SetPlayerPos(giveplayeridslxslyslz+5);
            
PlayerPlaySound(giveplayerid1130slxslyslz+5);
            
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command!");
    }
    return 
1;

I hope it will work for you


Re: How to slap ? - Jstylezzz - 20.07.2015

Probably with SetPlayerPos(x,y,z+4); where the 'z+4' is the original z height plus the amount to increase it with, thus lifting the player into the air. You might also be able to use SetPlayerVelocity for this, although I never looked into that function so I have no idea if that would work.

You could add a PlayPlayerSound to add a sound effect for it as well.

Hope this helps you in the right direction


Re: How to slap ? - FreddiewJO - 20.07.2015

I use SetPlayerPos(playerid, x, y, z+3)


Re: How to slap ? - Crystallize - 20.07.2015

Код:
CMD:slap(playerid,params[])
{
	if(pInfo[playerid][pAdminLevel] >= 2 || IsPlayerAdmin(playerid))
	{
	    new targetid,string[128];
		if(sscanf(params, "u", targetid)) return  SendClientMessage(playerid,-1,""chat" /slap [playerid]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

		new Float:posxx[3];
		GetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]);
		SetPlayerPos(targetid, posxx[0], posxx[1], posxx[2]+40);

		if(IsPlayerAdmin(playerid))
		{
	   		format(string, sizeof(string), "*"COL_RED" RCON Admin has slapped %s",PlayerName(targetid));
			 SendMessageToAllAdmins(string,-1);

		}
		else
		{
			format(string, sizeof(string), "*"COL_RED" %s %s has slapped %s",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
			 SendMessageToAllAdmins(string,-1);
		}
	}
	else {
		SendClientMessage(playerid,-1,"*"COL_RED" You do not have the right admin permissions for this command!");
	}
	return 1;
}
Replace the variables with your own


Re: How to slap ? - suni - 24.07.2015

zcmd slap
Quote:

CMDlap(playerid, params[])
{
new Float, Float:y, Float:z, Float:health;
new str[128], id, reason[128];
if(PlayerAcc[playerid][Admin] >= 3)// replace this
{
if(sscanf(params, "u[128]", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Slap: /slap (id) (reason)");
if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
if(id == playerid) return ErrorMessages(playerid, 4);
if(PlayerAcc[id][Jail] == 1) return SendClientMessage(playerid, COLOR_RED, "That player is in jail (Unable to slap!)");// replace this too
GetPlayerPos(id, x, y, z);
GetPlayerHealth(id, health);
SetPlayerHealth(id, health-25);
SetPlayerPos(id, x, y, z+5);
format(str, sizeof(str), "%s(%d) has been slap by Admin %s(%d)", GetName(id), id, GetName(playerid), playerid, GetPlayerHealth(id, health));
SendClientMessageToAll(COLOR_GREEN, str);
PlayerPlaySound(playerid, 1190, 0.0, 0.0, 0.0);
PlayerPlaySound(id, 1190, 0.0, 0.0, 0.0);
}
return 1;
}




Re: How to slap ? - Skillex333 - 24.07.2015

To my understanding it is essentially just increasing the "z" co-ordinate to whatever height you desire. So say you were to move slap the player up by 10 you'd replace the z in (x,y,z) with "z+10".

Hope this helped.


Re: How to slap ? - TenTen - 24.07.2015

Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z+3);



Re: How to slap ? - XBrianX - 24.07.2015

Use my code.

PHP код:
CMD:slap(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pModerator] >= 1)
    {
        if(
AdminDuty[playerid] != && PlayerInfo[playerid][pAdmin] < 5)
        {
            
SendClientMessage(playerid,COLOR_WHITE"You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
            return 
1;
        }
        new 
string[128], giveplayerid;
        if(
sscanf(params"u"giveplayerid)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /slap [playerid/partofname]");
        if(
PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
        {
            
SendClientMessage(playerid,COLOR_WHITE"You can't slap a higher admin.");
            return 
1;
        }
        new
            
Float:shealth;
        if(
IsPlayerConnected(giveplayerid)) {
            
GetPlayerHealth(giveplayeridshealth);
            
SetPlayerHealth(giveplayeridshealth-5);
            
GetPlayerPos(giveplayeridPlayerInfo[giveplayerid][pPos_x], PlayerInfo[giveplayerid][pPos_y], PlayerInfo[giveplayerid][pPos_z]);
            
SetPlayerPos(giveplayeridPlayerInfo[giveplayerid][pPos_x], PlayerInfo[giveplayerid][pPos_y], PlayerInfo[giveplayerid][pPos_z]+5);
            
PlayerPlaySound(giveplayerid1130PlayerInfo[giveplayerid][pPos_x], PlayerInfo[giveplayerid][pPos_y], PlayerInfo[giveplayerid][pPos_z]+5);
            
format(stringsizeof(string), "AdmCmd: %s was slapped by %s",GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid));
            
ABroadCast(COLOR_LIGHTRED,string,2);
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GRAD1"You're not authorized to use that command!");
    }
    return 
1;

Please REP+1 me.