How to slap ?
#1

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.
Reply
#2

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);
Reply
#3

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
Reply
#4

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
Reply
#5

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

Код:
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
Reply
#7

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;
}

Reply
#8

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.
Reply
#9

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)