Bug: System Damage RNPC bot
#1

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(idplayerid);
    public 
WatchTimer(idplayerid) {
            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:xFloat:yFloat:z;
                    
GetPlayerPos(rpol[id][RPOL_CURTARGET], x,z);
                    if (!
IsPlayerInRangeOfPoint(rpol[id][RPOL_NPCID], RPOL_VISIONRANGE 2.0xyz)
                            || 
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_ATTACKRANGExyz)) {
                            
// Target is in attackrange
                            // Stop running and start shhoting
                            
                            
new Float:oxFloat:oyFloat:oz;
                            
GetPlayerPos(rpol[id][RPOL_NPCID], oxoyoz);
                            
// Angle to the target
                            
new Float:angle atan2(ox xoy 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_ONFOOT1);
                            
// Set facing angle to the target
                            
RNPC_SetAngleQuats(0.0angle0.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(xyzRNPC_SPEED_RUN);
                            
// Finish build
                            
RNPC_FinishBuild();
                            
// Start playback
                            
RNPC_StartBuildPlayback(id1);
                            
                            
                    } else {
                                  
                           
                            
// Stop shooting
                            
RNPC_SetKeys(0);
                            
// Move towards the targets
                            
MoveRNPC(rpol[id][RPOL_NPCID], xyzRNPC_SPEED_RUN);
                    }
            }
    }
    
public 
Damage(playerid){
new 
Float:zxFloat:zyFloat:zz;
for(new 
0iMAX_PLAYERSi++)
{
        if(!
IsPlayerRNPC(i))
        {
            if (
IsPlayerConnected(i))
                   {
                
GetPlayerPos(izxzyzz);
                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;



Reply
#2

Can someone help me with this bug??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)