04.08.2018, 00:09
(
Последний раз редактировалось bookknp; 04.08.2018 в 00:57.
)
hello guys, I created a damage system with 25% success, the damage system works perfectly, but when you die the RNPC bot follows you and spawn in you zone, too changes Skin. Can you check the code and tell me if something is wrong??
PHP код:
forward WatchTimer(id, playerid);
public WatchTimer(id, playerid) {
if(rpol[id][RPOL_CURTARGET] == -1)
{
MoveRNPC(rpol[id][RPOL_NPCID], rpol[id][RPOL_WAYPOINTS_X][rpol[id][RPOL_NEXTWP]],
rpol[id][RPOL_WAYPOINTS_Y][rpol[id][RPOL_NEXTWP]], rpol[id][RPOL_WAYPOINTS_Z][rpol[id][RPOL_NEXTWP]],
RNPC_SPEED_WALK);
return;
}
if (rpol[id][RPOL_CURTARGET] > -1) {
new Float:x, Float:y, Float:z;
GetPlayerPos(rpol[id][RPOL_CURTARGET], x, y ,z);
if (!IsPlayerInRangeOfPoint(rpol[id][RPOL_NPCID], RPOL_VISIONRANGE * 2.0, x, y, z)
|| GetPlayerState(rpol[id][RPOL_CURTARGET]) != PLAYER_STATE_ONFOOT) {
// Target escaped or died
// Stop shooting
RNPC_SetKeys(0);
// Continue route
MoveRNPC(rpol[id][RPOL_NPCID], rpol[id][RPOL_WAYPOINTS_X][rpol[id][RPOL_NEXTWP]],
rpol[id][RPOL_WAYPOINTS_Y][rpol[id][RPOL_NEXTWP]], rpol[id][RPOL_WAYPOINTS_Z][rpol[id][RPOL_NEXTWP]],
RNPC_SPEED_WALK);
rpol[id][RPOL_CURTARGET] = -1;
return;
} else
if (IsPlayerInRangeOfPoint(rpol[id][RPOL_NPCID], RPOL_ATTACKRANGE, x, y, z)) {
// Target is in attackrange
// Stop running and start shhoting
new Float:ox, Float:oy, Float:oz;
GetPlayerPos(rpol[id][RPOL_NPCID], ox, oy, oz);
// Angle to the target
new Float:angle = atan2(ox - x, oy - y) + 180.0;
// Stop and build, alternate slot for security
RNPC_StopPlayback(rpol[id][RPOL_NPCID]);
RNPC_CreateBuild(rpol[id][RPOL_NPCID], PLAYER_RECORDING_TYPE_ONFOOT, 1);
// Set facing angle to the target
RNPC_SetAngleQuats(0.0, angle, 0.0);
RNPC_SetWeaponID(22);
// Set Weapon
// Start firing
if(RNPC_SetKeys(4)){
SetTimer("Damage",200,false);}
// Move towards the target from the current position
RNPC_ConcatMovement(x, y, z, RNPC_SPEED_RUN);
// Finish build
RNPC_FinishBuild();
// Start playback
RNPC_StartBuildPlayback(id, 1);
} else {
// Stop shooting
RNPC_SetKeys(0);
// Move towards the targets
MoveRNPC(rpol[id][RPOL_NPCID], x, y, z, RNPC_SPEED_RUN);
}
}
}
public Damage(playerid){
new Float:zx, Float:zy, Float:zz;
for(new i = 0; i< MAX_PLAYERS; i++)
{
if(!IsPlayerRNPC(i))
{
if (IsPlayerConnected(i))
{
GetPlayerPos(i, zx, zy, zz);
if(IsPlayerInRangeOfPoint(i,15.0,zx,zy,zz))
{
if(RNPC_SetWeaponID(22)){
switch(random(12)){
case 0,1,2,3:{
new damage = 8;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(23)){
switch(random(12)){
case 0,1,2,3:{
new damage = 13;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(24)){
switch(random(12)){
case 0,1,2,3:{
new damage = 46;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(25)){
switch(random(12)){
case 0,1,2,3:{
new damage = 30;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(26)){
switch(random(12)){
case 0,1,2,3:{
new damage = 30;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(27)){
switch(random(12)){
case 0,1,2,3:{
new damage = 30;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(28)){
switch(random(12)){
case 0,1,2,3:{
new damage = 7;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(29)){
switch(random(12)){
case 0,1,2,3:{
new damage = 7;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(30)){
switch(random(12)){
case 0,1,2,3:{
new damage = 9;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(31)){
switch(random(12)){
case 0,1,2,3:{
new damage = 10;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(32)){
switch(random(12)){
case 0,1,2,3:{
new damage = 10;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(33)){
switch(random(12)){
case 0,1,2,3:{
new damage = 25;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
else if(RNPC_SetWeaponID(34)){
switch(random(12)){
case 0,1,2,3:{
new damage = 41;
new Float:healtu;
GetPlayerHealth(i,healtu);
SetPlayerHealth(i,healtu-damage);
}
case 4,5,6,7,8,9,10,11: return 1;
}}
}
else {}
}
}
}
return 1;
}