NPC help ! it must be work !
#1

hi to everyone ! I need much help right now

So i'm trying to ... if i enter a cmd THEN should the npc's play but ... idk
This is what i have:

<DELETED>

And about the cmd ...
pawn Код:
if(strcmp(cmdtext,"/backup1",true) == 0)
    {
           
            ConnectNPC("Fireman1","firemen1makefirestation");
            ConnectNPC("Fireman2","firemen2makefirestation");
            ConnectNPC("Fireman3","firemen3makefirestation");
            Firemencar[1] = AddStaticVehicle(407,-2022.4456,93.0133,28.3217,272.4218,3,1);
            Firemencar[2] = AddStaticVehicle(407,-2022.2397,83.8559,28.2866,270.2873,3,1);
            Firemencar[3] = AddStaticVehicle(407,-2022.3734,75.7672,28.3362,272.2477,3,1);
           
        if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
        {
            new npcname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
            if(!strcmp(npcname, "Fireman1", true)) //Checking if the NPC's name is MyFirstNPC
            {
              PutPlayerInVehicle(playerid, Firemencar[1], 0); //Putting the NPC into the vehicle we created for it.
            }
            if(!strcmp(npcname, "Fireman2",true))
            {
                PutPlayerInVehicle(playerid, Firemencar[2],0);
            }
            if(!strcmp(npcname,"Fireman3",true))
            {
                PutPlayerInVehicle(playerid, Firemencar[3],0);
            }
            return 1;
        }
        //StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen1makefirestation");
        //StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen2makefirestation");
        //StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen3makefirestation");
        SendClientMessageToAll(COLOR_PINK,"[BACKUP] Backup is coming for the flames at the train station !");
        return 1;
    }
Cmon guys THIS MUST BE WORK ... or not xD
It's a backup cmd so 3 npc are going to one place ...
I have something like 5 cmds !

HELP ! ^^
Reply
#2

On the first script, try adding: #include <a_samp> and/or #include <a_npc>

This forum requires that you wait 60 seconds between posts. Please try again in 24 seconds.
Reply
#3

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
On the first script, try adding: #include <a_samp> and/or #include <a_npc>

This forum requires that you wait 60 seconds between posts. Please try again in 24 seconds.
Ok ...

Those include ... i have it already in my script :d
Reply
#4

In that above script?
In that case I have no f*cking idea why you get that xD. Try take a look at the includes if those functions even exists. Try re-downloading the samp server package (0.3c) and replace all the pawno/include from the download to your pawno/include folder
Reply
#5

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
In that above script?
In that case I have no f*cking idea why you get that xD. Try take a look at the includes if those functions even exists. Try re-downloading the samp server package (0.3c) and replace all the pawno/include from the download to your pawno/include folder
Whoah xD are you crazy ?! im not re-dowloading the samp files xp
btw: those script above are all in one !
Reply
#6

I just checked mine a_npc and those forwards and native's were in it.
It should work xD - When you converted to 0.3c, did you replace the includes?
Reply
#7

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
I just checked mine a_npc and those forwards and native's were in it.
It should work xD - When you converted to 0.3c, did you replace the includes?
look:
pawn Код:
/*  SA-MP NPC Functions
 *
 *  © Copyright 2009, SA-MP Team
 *
 */


#if defined _samp_included
    #endinput
#endif
#define _samp_included
#pragma library samp

#pragma tabsize 4

#include <core>
#include <float>
#include <string>
#include <file>
#include <time>
#include <datagram>

// --------------------------------------------------
// Natives
// --------------------------------------------------

// Util
native print(const string[]);
native printf(const format[], {Float,_}:...);
native format(output[], len, const format[], {Float,_}:...);
native SetTimer(funcname[], interval, repeating);
native KillTimer(timerid);
native GetTickCount();
native Float:asin(Float:value);
native Float:acos(Float:value);
native Float:atan(Float:value);
native Float:atan2(Float:x, Float:y);

native SendChat(msg[]);
native SendCommand(commandtext[]);

native GetPlayerState(playerid);
native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z);
native GetPlayerVehicleID(playerid);
native GetPlayerArmedWeapon(playerid);
native GetPlayerHealth(playerid);
native GetPlayerArmour(playerid);
native GetPlayerSpecialAction(playerid);
native IsPlayerStreamedIn(playerid);
native IsVehicleStreamedIn(vehicleid);
native GetPlayerKeys(playerid, &keys, &updown, &leftright);
native GetPlayerFacingAngle(playerid, &Float:ang);
native GetMyPos(&Float:x, &Float:y, &Float:z);
native SetMyPos(Float:x, Float:y, Float:z);
native GetMyFacingAngle(&Float:ang);
native SetMyFacingAngle(Float:ang);

native GetDistanceFromMeToPoint(Float:X, Float:Y, Float:Z, &Float:Distance);
native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z);

native GetPlayerName(playerid, const name[], len);
native IsPlayerConnected(playerid);

#define PLAYER_RECORDING_TYPE_NONE      0
#define PLAYER_RECORDING_TYPE_DRIVER    1
#define PLAYER_RECORDING_TYPE_ONFOOT    2

native StartRecordingPlayback(playbacktype, recordname[]);
native StopRecordingPlayback();
native PauseRecordingPlayback();
native ResumeRecordingPlayback();

// --------------------------------------------------
// Defines
// --------------------------------------------------

// States
#define PLAYER_STATE_NONE                       (0)
#define PLAYER_STATE_ONFOOT                     (1)
#define PLAYER_STATE_DRIVER                     (2)
#define PLAYER_STATE_PASSENGER                  (3)
#define PLAYER_STATE_WASTED                     (7)
#define PLAYER_STATE_SPAWNED                    (8)
#define PLAYER_STATE_SPECTATING                 (9)

// Misc
#define MAX_PLAYER_NAME                         (24)
#define MAX_PLAYERS                             (500)
#define MAX_VEHICLES                            (2000)
#define INVALID_PLAYER_ID                       (0xFFFF)
#define INVALID_VEHICLE_ID                      (0xFFFF)
#define NO_TEAM                                 (255)
#define MAX_OBJECTS                             (150)
#define INVALID_OBJECT_ID                       (255)
#define MAX_GANG_ZONES                          (1024)
#define MAX_TEXT_DRAWS                          (1024)
#define MAX_MENUS                               (128)
#define INVALID_MENU                            (0xFF)
#define INVALID_TEXT_DRAW                       (0xFFFF)
#define INVALID_GANG_ZONE                       (-1)

// Weapons
#define WEAPON_BRASSKNUCKLE             (1)
#define WEAPON_GOLFCLUB                 (2)
#define WEAPON_NITESTICK                (3)
#define WEAPON_KNIFE                    (4)
#define WEAPON_BAT                      (5)
#define WEAPON_SHOVEL                   (6)
#define WEAPON_POOLSTICK                (7)
#define WEAPON_KATANA                   (8)
#define WEAPON_CHAINSAW                 (9)
#define WEAPON_DILDO                    (10)
#define WEAPON_DILDO2                   (11)
#define WEAPON_VIBRATOR                 (12)
#define WEAPON_VIBRATOR2                (13)
#define WEAPON_FLOWER                   (14)
#define WEAPON_CANE                     (15)
#define WEAPON_GRENADE                  (16)
#define WEAPON_TEARGAS                  (17)
#define WEAPON_MOLTOV                   (18)
#define WEAPON_COLT45                   (22)
#define WEAPON_SILENCED                 (23)
#define WEAPON_DEAGLE                   (24)
#define WEAPON_SHOTGUN                  (25)
#define WEAPON_SAWEDOFF                 (26)
#define WEAPON_SHOTGSPA                 (27)
#define WEAPON_UZI                      (28)
#define WEAPON_MP5                      (29)
#define WEAPON_AK47                     (30)
#define WEAPON_M4                       (31)
#define WEAPON_TEC9                     (32)
#define WEAPON_RIFLE                    (33)
#define WEAPON_SNIPER                   (34)
#define WEAPON_ROCKETLAUNCHER           (35)
#define WEAPON_HEATSEEKER               (36)
#define WEAPON_FLAMETHROWER             (37)
#define WEAPON_MINIGUN                  (38)
#define WEAPON_SATCHEL                  (39)
#define WEAPON_BOMB                     (40)
#define WEAPON_SPRAYCAN                 (41)
#define WEAPON_FIREEXTINGUISHER         (42)
#define WEAPON_CAMERA                   (43)
#define WEAPON_PARACHUTE                (46)
#define WEAPON_VEHICLE                  (49)
#define WEAPON_DROWN                    (53)
#define WEAPON_COLLISION                (54)

// Keys
#define KEY_ACTION              (1)
#define KEY_CROUCH              (2)
#define KEY_FIRE                (4)
#define KEY_SPRINT              (8)
#define KEY_SECONDARY_ATTACK    (16)
#define KEY_JUMP                (32)
#define KEY_LOOK_RIGHT          (64)
#define KEY_HANDBRAKE           (128)
#define KEY_LOOK_LEFT           (256)
#define KEY_SUBMISSION          (512)
#define KEY_LOOK_BEHIND         (512)
#define KEY_WALK                (1024)
#define KEY_ANALOG_UP           (2048)
#define KEY_ANALOG_DOWN         (4096)
#define KEY_ANALOG_RIGHT        (16384)
#define KEY_ANALOG_LEFT         (8192)

#define KEY_UP                  (-128)
#define KEY_DOWN                (128)
#define KEY_LEFT                (-128)
#define KEY_RIGHT               (128)

// --------------------------------------------------
// Forwards (Callback declarations)
// --------------------------------------------------

forward OnNPCModeInit();
forward OnNPCModeExit();
forward OnNPCConnect(myplayerid);
forward OnNPCDisconnect(reason[]);
forward OnNPCSpawn();
forward OnNPCEnterVehicle(vehicleid, seatid);
forward OnNPCExitVehicle();
forward OnClientMessage(color, text[]);
forward OnPlayerDeath(playerid);
forward OnPlayerText(playerid, text[]);
forward OnPlayerStreamIn(playerid);
forward OnPlayerStreamOut(playerid);
forward OnVehicleStreamIn(vehicleid);
forward OnVehicleStreamOut(vehicleid);
forward OnRecordingPlaybackEnd();

// --------------------------------------------------
Reply
#8

rofl
Reply
#9

Quote:
Originally Posted by Michael@Belgium
Посмотреть сообщение
btw: those script above are all in one !
Thats the problem!

The npc files need to be in npcmodes/
And npc functions can be used in gamemodes or filterscripts

Just create there a new pwn file and put all npc stuff in there
Looks like you got three npcs, so we need three files

Like that
pawn Код:
// npcmodes/firemen1.pwn

#include <a_npc>

public OnNPCEnterVehicle(vehicleid, seatid)
    StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen1makefirestation");
public OnNPCExitVehicle(vehicleid, seatid) StopRecordingPlayback();

// npcmodes/firemen2.pwn

#include <a_npc>

public OnNPCEnterVehicle(vehicleid, seatid)
    StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen2makefirestation");
public OnNPCExitVehicle(vehicleid, seatid) StopRecordingPlayback();

// npcmodes/firemen3.pwn

#include <a_npc>

public OnNPCEnterVehicle(vehicleid, seatid)
    StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "firemen3makefirestation");
public OnNPCExitVehicle(vehicleid, seatid) StopRecordingPlayback();
To your command

1. AddStaticVehicle can only be used in OnGameModeInit, use CreateVehicle or put it in OnGameModeInit
2. You check if the player who typed the cmd is a npc which is obviously not the case

pawn Код:
//OnGameModeInit
    //arrays start with 0
    Firemencar[0] = AddStaticVehicle(407,-2022.4456,93.0133,28.3217,272.4218,3,1);
    Firemencar[1] = AddStaticVehicle(407,-2022.2397,83.8559,28.2866,270.2873,3,1);
    Firemencar[2] = AddStaticVehicle(407,-2022.3734,75.7672,28.3362,272.2477,3,1);
pawn Код:
//OnPlayerCommandText
    if(strcmp(cmdtext,"/backup1",true) == 0)
    {
        ConnectNPC("Fireman1","firemen1"); //we need to put there the the NPC scriptname
        ConnectNPC("Fireman2","firemen2"); //which I named above fireman1-3.pwn
        ConnectNPC("Fireman3","firemen3"); //just without the extention
        SendClientMessageToAll(COLOR_PINK,"[BACKUP] Backup is coming for the flames at the train station !");
        return 1;
    }
pawn Код:
//OnPlayerSpawn
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "Fireman1", true)) {
            PutPlayerInVehicle(playerid, Firemencar[0], 0);
        } else if(!strcmp(npcname, "Fireman2",true)) {
            PutPlayerInVehicle(playerid, Firemencar[1],0);
        } else if(!strcmp(npcname,"Fireman3",true)) {
            PutPlayerInVehicle(playerid, Firemencar[2],0);
        }
        return 1;
    }
In the end I can only advice you to read the npc tutorial again but a bit more clearly ^^"
Reply
#10

Ok it works now tysm !
But ofcourse if i type the cmd then the npc's joins into the server, then they playing. But i want that the npc's just play one time if i enter the cmd ?! How i should do that ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)