Originally Posted by [FeK]DraKiNs
Good working Mauzen !!
I am creating a system of zombies, advise the use of RNPC !!
Kill NPC
pawn Code:
// top of gm new tirosLevados[MAX_PLAYERS];
// onplayer update static targetplayer, Keys,ud,lr; GetPlayerKeys(playerid,Keys,ud,lr); targetplayer = GetPlayerTargetPlayer(playerid);
if(targetplayer != INVALID_PLAYER_ID && Keys == KEY_FIRE || Keys == 132) { if(IsPlayerNPC(targetplayer)) { tirosLevados[targetplayer]++; SetPVarInt(playerid, "timesTick", GetTickCount()); if(tirosLevados[targetplayer] > 20) { // 20 shoots +- SpawnPlayer(targetplayer); OnPlayerDeath(targetplayer, playerid, GetPlayerWeapon(playerid)); tirosLevados[targetplayer] = 0; } } }
Follow
pawn Code:
CHK_RowMoviment(n, moviment) {
if(moviment > rowNPCMove[n]) { return false; } static rowSTR[3][32];
format(rowSTR[0], 32, "rowNPC%dX", moviment); format(rowSTR[1], 32, "rowNPC%dY", moviment); format(rowSTR[2], 32, "rowNPC%dZ", moviment);
return IsPlayerInRangeOfPoint(n, 1.5, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2])); }
EXE_RowMoviment(n) {
if(!rowNPCMove[n] || execROWMoviment[n] > (rowNPCMove[n] - 1)) { return false; }
if(execROWMoviment[n]) { if(!CHK_RowMoviment(n, execROWMoviment[n]-1)) { return false; } }
static rowSTR[4][32];
if(execROWMoviment[n] > 1) { for(new i = execROWMoviment[n]-1; i > -1; i--) { format(rowSTR[0], 32, "rowNPC%dX", i); format(rowSTR[1], 32, "rowNPC%dY", i); format(rowSTR[2], 32, "rowNPC%dZ", i); format(rowSTR[3], 32, "rowNPC%dS", i);
DeletePVar(n,rowSTR[0]); DeletePVar(n,rowSTR[1]); DeletePVar(n,rowSTR[2]); DeletePVar(n,rowSTR[3]); } } format(rowSTR[0], 32, "rowNPC%dX", execROWMoviment[n]); format(rowSTR[1], 32, "rowNPC%dY", execROWMoviment[n]); format(rowSTR[2], 32, "rowNPC%dZ", execROWMoviment[n]); format(rowSTR[3], 32, "rowNPC%dS", execROWMoviment[n]); MoveRNPC(n, GetPVarFloat(n, rowSTR[0]),GetPVarFloat(n, rowSTR[1]),GetPVarFloat(n, rowSTR[2]),GetPVarFloat(n, rowSTR[3]));
return execROWMoviment[n]++; }
ADD_RowMoviment(n, Float:x, Float:y, Float:z, Float:s) {
static str[32];
format(str, 32, "rowNPC%dX", rowNPCMove[n]); SetPVarFloat(n, str, x); format(str, 32, "rowNPC%dY", rowNPCMove[n]); SetPVarFloat(n, str, y); format(str, 32, "rowNPC%dZ", rowNPCMove[n]); SetPVarFloat(n, str, z); format(str, 32, "rowNPC%dS", rowNPCMove[n]); SetPVarFloat(n, str, s);
return rowNPCMove[n]++; }
Now use:
pawn Code:
ADD_RowMoviment(npcid, x-0.1, y-0.1, z,0.006); // MoveRNPC(npcid, x-0.1, y-0.1, z,0.006); EXE_RowMoviment(npcid);
pawn Code:
new execROWMoviment[MAX_PLAYERS]; new rowNPCMove[MAX_PLAYERS];
This follows exactly where the player walks. It can also be optimized ..
- So the NPC does not fly on the wall, or walk inside them or fly into holes
|