Need Help. - 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: Need Help. (
/showthread.php?tid=634136)
Need Help. -
ongnung147 - 14.05.2017
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
PlayerShotPlayer[issuerid][playerid] = 1;
new Float:HP;
GetPlayerHealth(playerid, HP);
if(team[issuerid] != team[playerid])
{
if(weaponid == 4)
{
SetPlayerHealth(playerid, HP-35);
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == 1 || pInfo[issuerid][pKickBackCoin])
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31)
{
new Float:x,Float:y,Float:z,Float:angle;
GetPlayerFacingAngle(playerid,Float:angle);
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
SetPlayerVelocity(playerid,Float:x+0.1,Float:y+0.1,Float:z+0.2);
SetPlayerFacingAngle(playerid,Float:angle);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == VIPSCOUT)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34)
{
SetPlayerHealth(playerid, -0);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == SCOUT || pInfo[issuerid][pHumanClass] == HEAVYSHOTGUN || pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pDamageShotgunCoin] == 1)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34 || 25)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid, hp - 45);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pDamageMP5Coin] == 1 || pInfo[issuerid][pDamageDeagleCoin] == 1)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 24 || 29)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid, hp - 45);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == SNIPER)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34 && bodypart == 9)
{
SetPlayerHealth(playerid, -0);
GameTextForPlayer(playerid, "~n~~r~HEADSHOT", 3000, 3);
GameTextForPlayer(issuerid, "~n~~g~HEADSHOT", 3000, 3);
new Float:x, Float:y, Float:z, Float:fDistance, hsMessage[90], KName[MAX_PLAYER_NAME], PName[MAX_PLAYER_NAME];
GetPlayerPos(playerid, x, y, z);
fDistance = GetPlayerDistanceFromPoint(issuerid, x, y, z);
GetPlayerName(issuerid, KName, MAX_PLAYER_NAME);
GetPlayerName(playerid, PName, MAX_PLAYER_NAME);
format(hsMessage, sizeof(hsMessage), "{DC143C}%s has Headshotted {FFFFFF}%s{DC143C} from the distance of %0.2f", KName, PName, fDistance);
SendClientMessageToAll(-1, hsMessage);
pInfo[issuerid][pHeads]++;
}
}
}
}
return 1;
}
Код:
[debug] Run time error 4: "Array index out of bounds"
[09:37:28] [debug] Accessing element at index 65535 past array upper bound 999
[09:37:28] [debug] AMX backtrace:
[09:37:28] [debug] #0 00037108 in ?? (... <5 arguments>) at D:\123\gamemodes\zma.pwn:2508
[09:37:28] [debug] #1 000103a0 in public OnPlayerTakeDamage (playerid=0, issuerid=65535, Float:amount=4.95000, weaponid=54, bodypart=3) at C:\Documents and Settings\Admin\Desktop\Execute Compiler\include\YSI\y_hooks/impl.inc:2343
Re: Need Help. -
Fairuz - 14.05.2017
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
PlayerShotPlayer[issuerid][playerid] = 1;
new Float:HP;
GetPlayerHealth(playerid, HP);
if(team[issuerid] != team[playerid])
{
if(weaponid == 4)
{
SetPlayerHealth(playerid, HP-35);
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pVipKickBack] == 1 || pInfo[issuerid][pKickBackCoin])
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 23 || weaponid == 25 || weaponid == 24 || weaponid == 34 || weaponid == 31)
{
new Float:x,Float:y,Float:z,Float:angle;
GetPlayerFacingAngle(playerid,Float:angle);
GetPlayerVelocity(playerid,Float:x,Float:y,Float:z);
SetPlayerVelocity(playerid,Float:x+0.1,Float:y+0.1,Float:z+0.2);
SetPlayerFacingAngle(playerid,Float:angle);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == VIPSCOUT)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34)
{
SetPlayerHealth(playerid, -0);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == SCOUT || pInfo[issuerid][pHumanClass] == HEAVYSHOTGUN || pInfo[issuerid][pHumanClass] == KICKBACK || pInfo[issuerid][pDamageShotgunCoin] == 1)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34 || 25)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid, hp - 45);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pDamageMP5Coin] == 1 || pInfo[issuerid][pDamageDeagleCoin] == 1)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 24 || 29)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
SetPlayerHealth(playerid, hp - 45);
}
}
}
}
if(team[issuerid] == TEAM_HUMAN)
{
if(pInfo[issuerid][pHumanClass] == SNIPER)
{
if(team[playerid] == TEAM_ZOMBIE)
{
if(weaponid == 34 && bodypart == 9)
{
SetPlayerHealth(playerid, -0);
GameTextForPlayer(playerid, "~n~~r~HEADSHOT", 3000, 3);
GameTextForPlayer(issuerid, "~n~~g~HEADSHOT", 3000, 3);
new Float:x, Float:y, Float:z, Float:fDistance, hsMessage[90], KName[MAX_PLAYER_NAME], PName[MAX_PLAYER_NAME];
GetPlayerPos(playerid, x, y, z);
fDistance = GetPlayerDistanceFromPoint(issuerid, x, y, z);
GetPlayerName(issuerid, KName, MAX_PLAYER_NAME);
GetPlayerName(playerid, PName, MAX_PLAYER_NAME);
format(hsMessage, sizeof(hsMessage), "{DC143C}%s has Headshotted {FFFFFF}%s{DC143C} from the distance of %0.2f", KName, PName, fDistance);
SendClientMessageToAll(-1, hsMessage);
pInfo[issuerid][pHeads]++;
}
}
}
}
}
return 1;
}
Re: Need Help. -
ongnung147 - 14.05.2017
thanks
Re: Need Help. -
zedshadowzw - 15.05.2017
solved my problem too! thanks a lot