+REP IF HELP! , Is Can put..
#1

Hello, i 'v this code
Код:
#define SERVER_MAX_PLAYERS 20 //Change to max players of your server

//define SHOWPATH if you want the path of bullet to be shown
//#define SHOWPATH

public OnFilterScriptInit()
{
	print("\n\n__________________________________________________________________");
	print(" Boom Headshot System by Johnson_boy loaded!");
	print(" Copyright Johnson_boy 2010");
	print("__________________________________________________________________\n\n");
	return 1;
}

public OnFilterScriptExit()
{
    print("\n\n__________________________________________________________________");
	print(" Boom Headshot System by Johnson_boy unloaded!");
	print(" Copyright Johnson_boy 2010");
	print("__________________________________________________________________\n\n");
	return 1;
}

public OnPlayerConnect(playerid) {
 	SendClientMessage(playerid, 0xFFFFFFFF, "This server is using Johnson_boy's Headshot script");
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_FIRE && newkeys & KEY_HANDBRAKE) {
	    if(GetPlayerWeapon(playerid) == 34 || GetPlayerWeapon(playerid) == 24 || GetPlayerWeapon(playerid) == 30 || GetPlayerWeapon(playerid) == 22 || GetPlayerWeapon(playerid) == 23) {
	        new Float:blahx, Float:blahy, Float:blahz;
			HeadshotCheck(playerid, blahx, blahy, blahz);
	        return 1;
	    }
		return 1;
 	}
	return 1;
}

stock PlayerName(playerid) {
	new name[24];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}

stock HeadshotCheck(playerid, &Float:x, &Float:y, &Float:z) {
	new Float:fx,Float:fy,Float:fz;
	GetPlayerCameraFrontVector(playerid, fx, fy, fz);

 	new Float:cx,Float:cy,Float:cz;
 	GetPlayerCameraPos(playerid, cx, cy, cz);

	for(new Float:i = 0.0; i < 50; i = i + 0.5) {
 		x = fx * i + cx;
		y = fy * i + cy;
		z = fz * i + cz;

		#if defined SHOWPATH
		CreatePickup(1239, 4, x, y, z, -1);
		#endif

		for(new player = 0; player < SERVER_MAX_PLAYERS; player ++) {
		    if(IsPlayerInRangeOfPoint(player, 0.3, x, y, z - 0.7)) {
				if(player != playerid) {
					new string[128];
					format(string, sizeof(string), "Headshot: %s was shot to head by %s", PlayerName(player), PlayerName(playerid));
					SendClientMessageToAll(0xFF9900AA, string);
					GameTextForPlayer(playerid, "~r~HEADSHOT!", 2000, 6);
					GameTextForPlayer(player, "~r~HEADSHOT!", 2000, 6);
					SetPlayerHealth(player, 0.0);
				}
			}
		}
	}
	return 1;
}
At line "if(GetPlayerWeapon(playerid) == 34) {" It's so only for sniper ! how to put it for allweapons??
Reply
#2

Delete the condition? Really, it couldn't be much simpler ...
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Delete the condition? Really, it couldn't be much simpler ...
Its not working i tried this before
Reply
#4

Quote:
Originally Posted by [M.A]Angel[M.A]
Посмотреть сообщение
You meaning: if(GetPlayerWeapon(playerid))?
As far as I know, Vince said remove that condition..

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && newkeys & KEY_HANDBRAKE)
    {
        // condition removed...
        new Float:blahx, Float:blahy, Float:blahz;
        HeadshotCheck(playerid, blahx, blahy, blahz);
        return 1;
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Delete the condition? Really, it couldn't be much simpler ...
Dude i tried its not working ... only with sniper ??
Reply
#6

Nah, he wanted it so only the sniper could do it,

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_FIRE && newkeys & KEY_HANDBRAKE) {
	    if(GetPlayerWeapon(playerid) == 34) {
	        new Float:blahx, Float:blahy, Float:blahz;
			HeadshotCheck(playerid, blahx, blahy, blahz);
	        return 1;
	    }
		return 1;
 	}
	return 1;
}
Reply
#7

Before anything im now just know that headshot system is only for sniper... so i can't use it for all weapons.
Reply
#8

Dude, first learn english and secondly if you want it for ALL weapons do what Vince said. Otherwise do what Akira297 said. And otherwise you better start with the basics of pawn. The if condition is very basic...
Reply
#9

I m not should to learn eng, my lang is arabic..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)