• 06 Mai 2025, 08:09:58


Auteur Sujet: [ Non Résolu ] Problème installation NPC  (Lu 1564 fois)

0 Membres et 1 Invité sur ce sujet

Hors ligne MasterRace

  • *
  • Nouveau
  • Messages: 14
    • Voir le profil
[ Non Résolu ] Problème installation NPC
« le: 19 Décembre 2009, 14:55:09 »
Bonjour à tous !

J'ai essayé d'installer un NPC à partir du TUTO http://www.gtaonline.fr/forums/index.php/topic,8750.new.html#new

J'effectue correctement ce qu'il dit de faire mais ensuite je bloque ici :


Citation
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
    Code ...
}

et cela :

Citation
public OnPlayerRequestClass(playerid, classid)
{
   if(IsPlayerNPC(playerid)) return 1;
    Code ...
}

dans mon Gamemode Godfather mais je n'arrive pas à savoir ce qu'il faut mettre à la place de "Code...",
Citation
    if(IsPlayerNPC(playerid)) return 1;
    Code ...
, donc c'est logique que quand je compile sa me mette "Pawn Compiler à rencontré un problème et doit fermer ...." Grimaçant

Merci de m'aider  Clin d'oeil
« Modifié: 19 Décembre 2009, 15:10:12 par MasterRace »

Hors ligne ApocKalipsS

  • *
  • Gangster
  • **** | Une experience GTA IV hors du commun !
  • Messages: 1141
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #1 le: 19 Décembre 2009, 15:01:52 »
Tu peux aussi suivre ce tuto là : http://forum.sa-mp.com/index.php?topic=119947.0
Et celui qui est ici sur GTAOnline mais j'ai la flemme de chercher le lien  :laugh

Hors ligne MasterRace

  • *
  • Nouveau
  • Messages: 14
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #2 le: 19 Décembre 2009, 15:10:40 »

Hors ligne cristab

  • *
  • Messages: 8379
    • Voir le profil
pas d'aide en PM, vous êtes sur un forum est il me semble que vous êtes la pour avoir de l'aide donc pourquoi MP une seul personne qui ne vous répondra pas alors qu'il y a plein de membre ici

Hors ligne MasterRace

  • *
  • Nouveau
  • Messages: 14
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #4 le: 19 Décembre 2009, 16:42:36 »
J'ai suivis votre lien Cristab et voilà comment j'ai codé :

Citer
#include <a_samp>
#include <core>
#include <float>

#pragma tabsize 0

main()
{
   print("\n----------------------------------");
   print("  Bare Script\n");
   print("----------------------------------\n");
}

public OnPlayerConnect(playerid)
{
   GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
   return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
   new idx;
   new cmd[256];
   
   cmd = strtok(cmdtext, idx);

   if(strcmp(cmd, "/yadayada", true) == 0) {
       return 1;
   }

   return 0;
}

public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))// si le joueur est un BOT
    {
        new playername[MAX_PLAYER_NAME];
      GetPlayerName(playerid,playername,MAX_PLAYER_NAME);//on récupère sont pseudo
      if(!strcmp(playername,"bruno",true))//si sont pseudo est Bruno
      {
         SetPlayerSkin(playerid,62);//je désir lui mettre le skin 0
      }
   }
   else
   {
   SetPlayerInterior(playerid,0);
   TogglePlayerClock(playerid,0);  //ici ce trouve le reste de votre GM
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
      return 1;
}

SetupPlayerForClassSelection(playerid)
{
    SetPlayerInterior(playerid,14);
   SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
   SetPlayerFacingAngle(playerid, 270.0);
   SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
   SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerRequestClass(playerid, classid)
{
   SetupPlayerForClassSelection(playerid);
   return 1;
}

public OnGameModeInit()
{
    SetGameModeText("Bare Script");
   ShowPlayerMarkers(1);
   ShowNameTags(1);
   AllowAdminTeleport(1);

   AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);

    ConnectNPC("bot_1","Bruno"); //cette fonction permet de spawn un bot script BOT_1 Pseudo du bot Bruno
   return 1;
}


strtok(const string[], &index)
{
   new length = strlen(string);
   while ((index < length) && (string[index] <= ' '))
   {
      index++;
   }

   new offset = index;
   new result[20];
   while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
   {
      result[index - offset] = string[index];
      index++;
   }
   result[index - offset] = EOS;
   return result;
}

Est-ce bon ?? Parce que je vois rien sur le serveur........

J'utilise ce script pour tester

Hors ligne cristab

  • *
  • Messages: 8379
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #5 le: 19 Décembre 2009, 16:53:58 »
tu as bien fait l'autre script ?
pas d'aide en PM, vous êtes sur un forum est il me semble que vous êtes la pour avoir de l'aide donc pourquoi MP une seul personne qui ne vous répondra pas alors qu'il y a plein de membre ici

Hors ligne MasterRace

  • *
  • Nouveau
  • Messages: 14
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #6 le: 19 Décembre 2009, 17:00:01 »
Citer
#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(2, "Bruno");
public OnNPCSpawn() StartRecordingPlayback(2, "Bruno");

Celui là ? Placé dans Npcmodes ?

Oui...

Double post
Désolé du double post mais

Mon soucis c'est qu'est-ce que je met à la place de "Code..." ====>
Citation
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
    Code ...
}
??
« Modifié: 19 Décembre 2009, 17:24:41 par MasterRace »

Hors ligne ApocKalipsS

  • *
  • Gangster
  • **** | Une experience GTA IV hors du commun !
  • Messages: 1141
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #7 le: 19 Décembre 2009, 20:17:01 »
Tu es sur un GF/LARP ?
Si oui, passes nous les logs.
PS : Test avec le GM que tu nous a donné.

Hors ligne MasterRace

  • *
  • Nouveau
  • Messages: 14
    • Voir le profil
Re : [ Non Résolu ] Problème installation NPC
« Réponse #8 le: 19 Décembre 2009, 21:52:36 »
Je suis sur GF

Double post
Alors, voilà

Alors voilà, j'ai suivis ce tuto : http://forum.sa-mp.com/index.php?topic=119947.0 pour installer un NPC en voiture.

Je procédé comme tel :

- Je me suis connecté à mon serveur, j'ai installé un véhicule "/veh 560 3 3", puis j'ai "/save". J'ai récupéré la position du véhicule et j'ai placé la ligne dans "public OnGameModeInit()", puis dans "AddStaticVehicleEx" comme çà :

Citer
//------------------------------------Véhicules achetables----------------------------------------------------------------------------------------
 &nbsp; &nbsp;AddStaticVehicleEx(560,490.4265,-1489.0308,19.7264,347.2856,3,3, 60000); //sultan
   AddStaticVehicleEx(560,-2064.2214,-84.1129,34.8688,359.8634, 3,3, 60000);// Sultan à l'auto école
...........
.

Ensuite, je me suis connecté, je suis monté dans la voiture, je me suis logué en Rcon et j'ai commencé un enregistrement en voiture "/vrecord mynpc".

Une fois terminé, je suis allé dans le dossier "Scriptfiles", j'ai copié "mynpc.rec" dans Npcmodes/recording". Ensuite j'ai ouvert un nouveau fichier pawno et j'ai collé :

Citer
#define RECORDING "mynpc" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.

#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);

#if RECORDING_TYPE == 1
 &nbsp; &nbsp;public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
 &nbsp; &nbsp;public OnNPCExitVehicle() StopRecordingPlayback();
#else
 &nbsp; &nbsp;public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif

Je l'es enregistré sous "mynpc" dans "npcmodes".

Ensuite, j'ai ouvert mon Gamemode, j'ai cherché la ligne "public OnGameModeInit()", et j'ai collé :

Citer
new MyFirstNPCVehicle; //Global variable!
public OnGameModeInit()
{
 &nbsp; &nbsp;print("my gamemode");
 &nbsp; &nbsp;ConnectNPC("MyFirstNPC","mynpc");
 &nbsp; &nbsp;MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
 &nbsp; &nbsp;return 1;
}

Comme ceci :

Citer
//------------------------------------------------------------------------------------------------------
public OnGameModeInit()
{
 &nbsp; &nbsp;new string[MAX_PLAYER_NAME];
 &nbsp; &nbsp;new string1[MAX_PLAYER_NAME];
   for(new c=0;c<CAR_AMOUNT;c++)
   {
      Gas[c] = GasMax;
   }
   LoadProperty();
   LoadBizz();
   LoadSBizz();
   LoadBoxer();
   LoadStuff();
   LoadIRC();
   LoadFamilies();
   LoadCK();
   LoadTurfs();
   LoadPapers();
   IRCInfo[0][iPlayers] = 0; IRCInfo[1][iPlayers] = 0; IRCInfo[2][iPlayers] = 0;
   IRCInfo[3][iPlayers] = 0; IRCInfo[4][iPlayers] = 0; IRCInfo[5][iPlayers] = 0;
   IRCInfo[6][iPlayers] = 0; IRCInfo[7][iPlayers] = 0; IRCInfo[8][iPlayers] = 0;
   IRCInfo[9][iPlayers] = 0;
   News[hTaken1] = 0; News[hTaken2] = 0; News[hTaken3] = 0; News[hTaken4] = 0; News[hTaken5] = 0;
   format(string, sizeof(string), "Nothing");
   strmid(News[hAdd1], string, 0, strlen(string), 255);
   strmid(News[hAdd2], string, 0, strlen(string), 255);
   strmid(News[hAdd3], string, 0, strlen(string), 255);
   strmid(News[hAdd4], string, 0, strlen(string), 255);
   strmid(News[hAdd5], string, 0, strlen(string), 255);
   format(string1, sizeof(string1), "No-one");
   strmid(News[hContact1], string1, 0, strlen(string1), 255);
   strmid(News[hContact2], string1, 0, strlen(string1), 255);
   strmid(News[hContact3], string1, 0, strlen(string1), 255);
   strmid(News[hContact4], string1, 0, strlen(string1), 255);
   strmid(News[hContact5], string1, 0, strlen(string1), 255);
   PlayerHaul[78][pCapasity] = 100;
   PlayerHaul[79][pCapasity] = 100;
   PlayerHaul[80][pCapasity] = 50;
   PlayerHaul[81][pCapasity] = 50;
   SetGameModeText("The Godfather: LS/SF");
   format(objstore, sizeof(objstore), "MOLE: I got nothing, check back with me later.");
   format(cbjstore, sizeof(cbjstore), "HQ: There is nothing in your Vicinity, Out.");
   format(motd, sizeof(motd), "Welcome to the Role Play - The Godfather Server.");
   gettime(ghour, gminute, gsecond);
   FixHour(ghour);
   ghour = shifthour;
   if(!realtime)
   {
      SetWorldTime(wtime);
   }
   SetPDistance(10);
   EnableTirePopping(1);
   EnableZoneNames(1);
   AllowInteriorWeapons(1);
   AllowAdminTeleport(1);
   UsePlayerPedAnims();
   // CreatedCars check
   for(new i = 0; i < sizeof(CreatedCars); i++)
   {
    &nbsp; &nbsp;CreatedCars = 0;
   }
   // Zones
   for(new i = 0; i < sizeof(TurfInfo); i++)
   {
    &nbsp; &nbsp;Turfs = GangZoneCreate(TurfInfo[zMinX],TurfInfo[zMinY],TurfInfo[zMaxX],TurfInfo[zMaxY]);
   }
   // Player Class's
   for(new i = 0; i <= sizeof(Peds)-1; i++)
   {
      AddPlayerClass(Peds[0],1958.3783,1343.1572,1100.3746,269.1425,-1,-1,-1,-1,-1,-1);
   }
   // Car Spawns
   /*for(new h = 0; h < sizeof(HouseInfo); h++)
   {
      AddStaticVehicleEx(HouseInfo[h][hVec], HouseCarSpawns[h][0], HouseCarSpawns[h][1], HouseCarSpawns[h][2], HouseCarSpawns[h][3], HouseInfo[h][hVcol1], HouseInfo[h][hVcol2], 60000);
      gCarLock[h+1] = 1;
   }//34*/
   {
&nbsp; &nbsp;print("Paradize");
 &nbsp; &nbsp;ConnectNPC("MyFirstNPC","mynpc");
 &nbsp; &nbsp;MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);

}
.

et :

Citer
//------------------------------------[News]------------------------------------

new MyFirstNPCVehicle; //Global variable!
new Security = 0;

Ensuite, j'ai cherché "public OnPlayerSpawn(playerid)" et j'ai collé :

Citer
{
 &nbsp; &nbsp;if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
 &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp;new npcname[MAX_PLAYER_NAME];
 &nbsp; &nbsp; &nbsp; &nbsp;GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
 &nbsp; &nbsp; &nbsp; &nbsp;if(!strcmp(npcname, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;return 1;
 &nbsp; &nbsp;}
 &nbsp; &nbsp;//Other stuff for normal players goes here!
 &nbsp; &nbsp;return 1;
}

Comme ceci :

Citer
//----------npc---------------------------
 &nbsp; &nbsp;if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
 &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp;new npcname[MAX_PLAYER_NAME];
 &nbsp; &nbsp; &nbsp; &nbsp;GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
 &nbsp; &nbsp; &nbsp; &nbsp;if(!strcmp(npcname, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
 &nbsp; &nbsp; &nbsp; &nbsp;{
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
 &nbsp; &nbsp; &nbsp; &nbsp;}
 &nbsp; &nbsp; &nbsp; &nbsp;return 1;
 &nbsp; &nbsp;}
 &nbsp; &nbsp;//Other stuff for normal players goes here!
 &nbsp; &nbsp;return 1;
}

//--------------------------------------------------------------
public CKLog(string[])

Voilà, ensuite j'ai enregistré et compilé. Aucune erreur.
Je configure le server.cfg. Car "maxnpc" était de 0. J'ai donc mis "maxnpc 50".

Ensuite j'ai lancé mon serveur mais sur la fenêtre de commande, il m'affiche çà :



Pourquoi le bot ce connecte et ce déconnecte directement ??

Merci
« Modifié: 20 Décembre 2009, 10:42:09 par MasterRace »