SA-MP Forums Archive
Spec killer - 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: Spec killer (/showthread.php?tid=59823)



Spec killer - arnoldziux - 29.12.2008

Hello,
I was trying to make this thingy like when you get killed you spec the killer for like 10 second and then spawn again, but it doesent even show the killer it just points the vies to god knows where and you dont spawn after 10 second

This is the code
pawn Код:
#include <a_samp>
//------------------------------------------------------------------------------
#define KILLER_SPEC_TYPE_PLAYER 0
#define KILLER_SPEC_TYPE_NONE 1
//------------------------------------------------------------------------------
new gSpectateID[MAX_PLAYERS];
new gSpectateType[MAX_PLAYERS];
new CountdownTime = 10,CountdownTimer,CTime;

forward Countdown();
//------------------------------------------------------------------------------
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    new x = 0;
    while(x!=MAX_PLAYERS) {
      if( IsPlayerConnected(x) &&   GetPlayerState(x) == PLAYER_STATE_SPECTATING &&
            gSpectateID[x] == playerid && gSpectateType[x] == KILLER_SPEC_TYPE_PLAYER )
        {
          SetPlayerInterior(x,newinteriorid);
        }
        x++;
    }
}
//------------------------------------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason)
{
      new speckillerid;

        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, speckillerid);
        SetPlayerInterior(playerid,GetPlayerInterior(speckillerid));
        gSpectateID[playerid] = speckillerid;
        gSpectateType[playerid] = KILLER_SPEC_TYPE_PLAYER;
        return 1;
    }
//------------------------------------------------------------------------------
public Countdown()
{
    new playerid;
    CountdownTimer = SetTimer("Countdown",1000,1);
    CTime = CountdownTime;
    if(CTime == 0) {
    CTime = CountdownTime;
    KillTimer(CountdownTimer); }
    CTime--;
    TogglePlayerSpectating(playerid, 0);
    gSpectateID[playerid] = INVALID_PLAYER_ID;
    gSpectateType[playerid] = KILLER_SPEC_TYPE_NONE;
}
Can anybody help ?


Re: Spec killer - arnoldziux - 29.12.2008

Quote:
Originally Posted by Seif_
First: OnPlayerDeath doesn't only have playerid. Check again.
Second: you're defining speckillerid, which is automatically set as 0.
Yeh but if i dont define speckillerid

it gives me errors like

pawn Код:
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(30) : error 017: undefined symbol "speckillerid"
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(31) : error 017: undefined symbol "speckillerid"
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(32) : error 017: undefined symbol "speckillerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.



Re: Spec killer - arnoldziux - 29.12.2008

Quote:
Originally Posted by Seif_
Defining a variable like that won't find the killer magically. Press New button in PAWN and look at OnPlayerDeath.
lol, i press new and gues what
I get a blank page


Re: Spec killer - Serbish - 29.12.2008

Quote:
Originally Posted by [SLR
Assassin ]
Quote:
Originally Posted by Seif_
Defining a variable like that won't find the killer magically. Press New button in PAWN and look at OnPlayerDeath.
lol, i press new and gues what
I get a blank page
Too bad that my GM Nothing v0.1 got deleted.
That could help you.


Re: Spec killer - arnoldziux - 29.12.2008

Quote:
Originally Posted by -=[Serbish
=- ]
Quote:
Originally Posted by [SLR
Assassin ]
Quote:
Originally Posted by Seif_
Defining a variable like that won't find the killer magically. Press New button in PAWN and look at OnPlayerDeath.
lol, i press new and gues what
I get a blank page
Too bad that my GM Nothing v0.1 got deleted.
That could help you.
GM nothing ?


Re: Spec killer - arnoldziux - 29.12.2008

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by -=[Serbish
=- ]
Quote:
Originally Posted by [SLR
Assassin ]
Quote:
Originally Posted by Seif_
Defining a variable like that won't find the killer magically. Press New button in PAWN and look at OnPlayerDeath.
lol, i press new and gues what
I get a blank page
Too bad that my GM Nothing v0.1 got deleted.
That could help you.
It was spam just like most of your posts. And it couldn't have helped him in any way.
Quote:
Originally Posted by [SLR
Assassin ]
Quote:
Originally Posted by Seif_
Defining a variable like that won't find the killer magically. Press New button in PAWN and look at OnPlayerDeath.
lol, i press new and gues what
I get a blank page
Exactly, now look at OnPlayerDeath callback. It has "killerid" and "reason". That's the real callback. And that's what you need. Also, you can't spectate a player when you die, you need to spectate him when you spawn.
Alright Now i get you i'll try

EDIT:
pawn Код:
#include <a_samp>
//------------------------------------------------------------------------------
#define KILLER_SPEC_TYPE_PLAYER 0
#define KILLER_SPEC_TYPE_NONE 1
//------------------------------------------------------------------------------
new gSpectateID[MAX_PLAYERS];
new gSpectateType[MAX_PLAYERS];
new CountdownTime = 15,CountdownTimer,CTime;

forward Countdown();
//------------------------------------------------------------------------------
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    new x = 0;
    while(x!=MAX_PLAYERS) {
      if( IsPlayerConnected(x) &&   GetPlayerState(x) == PLAYER_STATE_SPECTATING &&
            gSpectateID[x] == playerid && gSpectateType[x] == KILLER_SPEC_TYPE_PLAYER )
        {
          SetPlayerInterior(x,newinteriorid);
        }
        x++;
    }
}
//------------------------------------------------------------------------------
public OnPlayerSpawn(playerid)
{
        new speckillerid;
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, speckillerid);
        SetPlayerInterior(playerid,GetPlayerInterior(speckillerid));
        gSpectateID[playerid] = speckillerid;
        gSpectateType[playerid] = KILLER_SPEC_TYPE_PLAYER;
      return 1;
}
//------------------------------------------------------------------------------
public Countdown()
{
    new playerid;
    CountdownTimer = SetTimer("Countdown",1000,1);
    CTime = CountdownTime;
    if(CTime == 0) {
    CTime = CountdownTime;
    KillTimer(CountdownTimer); }
    CTime--;
    TogglePlayerSpectating(playerid, 0);
    gSpectateID[playerid] = INVALID_PLAYER_ID;
    gSpectateType[playerid] = KILLER_SPEC_TYPE_NONE;
}
Something like this ?


Re: Spec killer - LarzI - 30.12.2008

You need to return false (return 0 and set a timer to spawn player when 10 seconds has gone


Re: Spec killer - _TeRmiNaToR_ - 27.03.2009

Quote:
Originally Posted by Jump3r
Quote:
Originally Posted by Seif_
First: OnPlayerDeath doesn't only have playerid. Check again.
Second: you're defining speckillerid, which is automatically set as 0.
Yeh but if i dont define speckillerid

it gives me errors like

pawn Код:
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(30) : error 017: undefined symbol "speckillerid"
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(31) : error 017: undefined symbol "speckillerid"
C:\Users\Arnoldziux\Documents\Top Secret\Serveris\filterscripts\adminspec.pwn(32) : error 017: undefined symbol "speckillerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Set the cpeckillerid to "killerid"


Re: Spec killer - [M.A]Angel[M.A] - 10.08.2012

Guys i need this code It is worked?
Код:
//------------------------------------------------------------------------------
#define KILLER_SPEC_TYPE_PLAYER 0
#define KILLER_SPEC_TYPE_NONE 1
//------------------------------------------------------------------------------
new gSpectateID[MAX_PLAYERS];
new gSpectateType[MAX_PLAYERS];
new CountdownTime = 15,CountdownTimer,CTime;

forward Countdown();
//------------------------------------------------------------------------------
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    new x = 0;
    while(x!=MAX_PLAYERS) {
      if( IsPlayerConnected(x) &&   GetPlayerState(x) == PLAYER_STATE_SPECTATING &&
            gSpectateID[x] == playerid && gSpectateType[x] == KILLER_SPEC_TYPE_PLAYER )
        {
          SetPlayerInterior(x,newinteriorid);
        }
        x++;
    }
}
//------------------------------------------------------------------------------
public OnPlayerSpawn(playerid)
{
        new speckillerid;
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, speckillerid);
        SetPlayerInterior(playerid,GetPlayerInterior(speckillerid));
        gSpectateID[playerid] = speckillerid;
        gSpectateType[playerid] = KILLER_SPEC_TYPE_PLAYER;
      return 1;
}
//------------------------------------------------------------------------------
public Countdown()
{
    new playerid;
    CountdownTimer = SetTimer("Countdown",1000,1);
    CTime = CountdownTime;
    if(CTime == 0) {
    CTime = CountdownTime;
    KillTimer(CountdownTimer); }
    CTime--;
    TogglePlayerSpectating(playerid, 0);
    gSpectateID[playerid] = INVALID_PLAYER_ID;
    gSpectateType[playerid] = KILLER_SPEC_TYPE_NONE;
}
MY SERVER:

Server forum
-------


Re: Spec killer - Vince - 10.08.2012

Does no one even realize that new variables are always initialized to 0? It's not like they magically get the value you want! If you want them to have a value, you must assign them a value! How hard is it to understand that?

Edit: just realized that poster above me bumped a 3 year old topic.