SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/12/2008, 11:55 PM   #1
arnoldziux
Huge Clucker
 
Join Date: Oct 2007
Posts: 230
Reputation: 0
Default Spec killer

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 Code:
#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 ?
arnoldziux is offline   Reply With Quote
Old 30/12/2008, 12:05 AM   #2
arnoldziux
Huge Clucker
 
Join Date: Oct 2007
Posts: 230
Reputation: 0
Default Re: Spec killer

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 Code:
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.
arnoldziux is offline   Reply With Quote
Old 30/12/2008, 12:22 AM   #3
arnoldziux
Huge Clucker
 
Join Date: Oct 2007
Posts: 230
Reputation: 0
Default Re: Spec killer

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
arnoldziux is offline   Reply With Quote
Old 30/12/2008, 12:24 AM   #4
Serbish
Gangsta
 
Join Date: Apr 2008
Location: Luxembourg
Posts: 643
Reputation: 30
Default Re: Spec killer

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.
Serbish is offline   Reply With Quote
Old 30/12/2008, 12:26 AM   #5
arnoldziux
Huge Clucker
 
Join Date: Oct 2007
Posts: 230
Reputation: 0
Default Re: Spec killer

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 ?
arnoldziux is offline   Reply With Quote
Old 30/12/2008, 12:38 AM   #6
arnoldziux
Huge Clucker
 
Join Date: Oct 2007
Posts: 230
Reputation: 0
Default Re: Spec killer

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 Code:
#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 ?
arnoldziux is offline   Reply With Quote
Old 30/12/2008, 02:56 AM   #7
LarzI
High-roller
 
LarzI's Avatar
 
Join Date: Apr 2007
Location: Norway
Posts: 3,552
Reputation: 130
Default Re: Spec killer

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


NEW: [FS] Simple Cellphones

if( strfind( title, "REP", true ) != -1 )
{________________________________________
Sigh();__________________________
}________________________________________


LarzI is offline   Reply With Quote
Old 27/03/2009, 03:32 PM   #8
_TeRmiNaToR_
Big Clucker
 
Join Date: Mar 2009
Posts: 96
Reputation: -1
Default Re: Spec killer

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 Code:
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"
_TeRmiNaToR_ is offline   Reply With Quote
Old 10/08/2012, 10:41 AM   #9
[M.A]Angel[M.A]
Huge Clucker
 
[M.A]Angel[M.A]'s Avatar
 
Join Date: Dec 2010
Location: Israel
Posts: 406
Reputation: 4
Default Re: Spec killer

Guys i need this code It is worked?
Code:
//------------------------------------------------------------------------------
#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
-------
[M.A]Angel[M.A] is offline   Reply With Quote
Old 10/08/2012, 10:58 AM   #10
Vince
Godfather
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 6,952
Reputation: 1822
Default Re: Spec killer

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.
__________________

Won't reply to your topic if you use outdated methods (strtok, dini, non-threaded MySQL).
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] Killer Info [1corp]vlad Filterscripts 8 14/06/2010 03:31 PM
An uknown killer... AcId n RaPiD Screenshots and Videos 6 21/02/2010 08:33 AM
Gta SA:MP : Creek Killer MaykoX Screenshots and Videos 0 02/02/2010 05:40 AM
Top killer Striker_Moe Help Archive 2 05/11/2009 08:48 AM
Top killer problem Striker_Moe Help Archive 0 02/11/2009 06:51 PM


All times are GMT. The time now is 03:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.