GTAOnline.net
San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: MasterRace 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 (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
-
Tu peux aussi suivre ce tuto là : http://forum.sa-mp.com/index.php?topic=119947.0 (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
-
Merci mais j'ai utilisé celui là : http://www.gtaonline.fr/forums/index.php/topic,8750.new.html#new (http://www.gtaonline.fr/forums/index.php/topic,8750.new.html#new)
-
regarde la http://www.gtaonline.fr/forums/index.php/topic,9219.0.html (http://www.gtaonline.fr/forums/index.php/topic,9219.0.html)
-
J'ai suivis votre lien Cristab et voilà comment j'ai codé :
#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
-
tu as bien fait l'autre script ?
-
#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 ...
}
??
-
Tu es sur un GF/LARP ?
Si oui, passes nous les logs.
PS : Test avec le GM que tu nous a donné.
-
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 (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 çà :
//------------------------------------Véhicules achetables----------------------------------------------------------------------------------------
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é :
#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
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();
#else
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é :
new MyFirstNPCVehicle; //Global variable!
public OnGameModeInit()
{
print("my gamemode");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
}
Comme ceci :
//------------------------------------------------------------------------------------------------------
public OnGameModeInit()
{
new string[MAX_PLAYER_NAME];
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++)
{
CreatedCars = 0;
}
// Zones
for(new i = 0; i < sizeof(TurfInfo); i++)
{
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*/
{
print("Paradize");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
}
.
et :
//------------------------------------[News]------------------------------------
new MyFirstNPCVehicle; //Global variable!
new Security = 0;
Ensuite, j'ai cherché "public OnPlayerSpawn(playerid)" et j'ai collé :
{
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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}
//Other stuff for normal players goes here!
return 1;
}
Comme ceci :
//----------npc---------------------------
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, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}
//Other stuff for normal players goes here!
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 çà :
(http://img7.hostingpics.net/pics/445161Sans_titre_1.jpg)
Pourquoi le bot ce connecte et ce déconnecte directement ??
Merci