Iniziare a scriptare è più semplice partendo da una pagina come questa:
#include <a_samp>
(In ogni script deve esserci questa scritta)
main()
{
print("\n----------------------------------");
print(" This is a blank GameModeScript");
print("----------------------------------\n");
}
public OnGameModeInit()
{
print("GameModeInit()");
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
printf("OnPlayerRequestClass(%d, %d)", playerid, classid);
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnGameModeExit()
{
print("GameModeExit()");
return 1;
}
public OnPlayerConnect(playerid)
{
printf("OnPlayerConnect(%d)", playerid);
return 1;
}
public OnPlayerDisconnect(playerid)
{
printf("OnPlayerDisconnect(%d)", playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
printf("OnPlayerSpawn(%d)", playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
printf("OnVehicleSpawn(%d)", vehicleid);
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
printf("OnVehicleDeath(%d, %d)", vehicleid, killerid);
return 1;
}
public OnPlayerText(playerid)
{
printf("OnPlayerText(%d)", playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/mycommand", true)==0)
{
/* Do something here */
return 1;
}
return 0;
}
public OnPlayerInfoChange(playerid)
{
printf("OnPlayerInfoChange(%d)");
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate);
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
printf("OnPlayerEnterCheckpoint(%d)", playerid);
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
printf("OnPlayerLeaveCheckpoint(%d)", playerid);
return 1;
}
Invece di copiare tutto il codice, andate nella cartella pawno e aprite il file new.pwn
Prima di iniziare, è utile definire alcune cose, come per esempio i colori
Per fare ciò, in testa a tutto lo script (sopra Main() per intenderci), copiate questo:
#define COLOR_RED 0xAA3333AA
a questo punto abbiamo definito il colore rosso.
altri colori sono:
Grigio: 0xAFAFAFAA
Verde: 0x33AA33AA
Giallo: 0xFFFF00AA
Blu: 0x1111AAFF
Arancione: 0xFF9900AA
Rosa: 0xFF66FFAA
Blu chiaro: 0x33CCFFAA
Rosso scuro: 0x660000AA
Se vogliamo definirli tutti, ecco cosa dovete scrivere:
// Colori
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_BLUE 0x1111AAFF
#define COLOR_PINK 0xFF66FFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
La scrittta // Colori non ha nessuno effetto perchè è preceduta dalle due //, ogni scritta preceduta da due // non fa assolutamente nulla. Voi vi chiederete, se non serve a nulla che la mette a fare? La si mette per fare ordine quando lo script
sarà molto più grande.
Molte volte si inserisce una vera e propria barra di separazione tra gli Eventi, come questa:
//---------------------------------------------------------
Cominciamo a parlare degli Eventi, che sono la parte essenziale del codice
Per esempio:
public OnPlayerSpawn(playerid)
SendClientMessage(playerid, color, const message[...] )
Esempio: SendClientMessage(playerid, COLOR_RED, "test");
public OnPlayerSpawn(playerid)
SendClientMessageToAll(color, const message[...] )
style: ci sono vari stili di GameText, eccone alcuni esempi:
Stile 1:
Stile 2:
Stile 3:
Stile 4: img
Stile 5:
Stile 6:
public OnPlayerSpawn(playerid)
GameTextForAll(const string[...], time, style )
SetTimer(funcname[...], interval, repeating )
Esempio:
SetTimer("DefenceWin", 600000, 0);
Per esempio, creiamo un timer:
Adesso, se avete capito tutto, possiamo iniziare il vero e proprio scripting...
SetGameModeText(const string[...])
Per esempio:
SetGameModeText("Area 51 Break-in");
SetTeamCount(4); // Ammette quattro squadre
AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo )
Esempio:
AddPlayerClass(23,-1404.5,518.15,18.2427,90,28,9000,27,9000,31,9000);
AddStaticVehicle( modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, IDcolor1, IDcolor2 )
AddStaticPickup( model, type, Float:X, Float:Y, Float:Z )
ShowNameTags(show)
Esempio:
// Visualizza Nicknames (predefinito)
// Nascondi Nicknames
ShowPlayerMarkers(show)
Show: inserisci 1 se vuoi vedere i segnalini dei giocatori, inserisci 0 se li vuoi nascondere
Esempio:
// Visualizza Seganlini (predefinito)
// Nascondi Segnalini
GameModeExit()
SetWorldTime(hour)
GetWeaponName(weaponid, const weapon[...], len)
GetPlayerName( playerid, const name[], len )
IsPlayerAdmin(playerid)
SetSpawnInfo( playerid, team, skin, Float:x, Float:y, Float:z, Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo )
SetPlayerTeam(playerid, teamid)
GetPlayerTeam(playerid, teamid)
SetPlayerSkin(playerid, skinid)
SetPlayerScore(playerid, score)
SetPlayerScore(playerid, 500);
GetPlayerScore(playerid)
public OnPlayerDeath(playerid, killerid, reason)
GetPlayerPos(playerid, & Float:x, & Float:y, & Float:z)
SetPlayerPos(playerid, Float:x, Float:y, Float:z)
GetPlayerHealth(playerid, & Float:health)
Esempio:
SetPlayerHealth(playerid, Float:health)
PutPlayerInVehicle(playerid, vehilcleid, seatid)
RemovePlayerFromVehicle(playerid)
IsPlayerInVehicle(playerid, vehicleid)
GetPlayerName(playerid, const name[], len)
GetPlayerColor(playerid)
GetPlayerVehicleID(playerid)
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size)
DisablePlayerCheckpoint(playerid)
IsPlayerInCheckpoint(playerid)
== GUIDA IN COSTRUZIONE ==
Durata Lavoro 2ore e mezza
Fonte:
#include <a_samp>
(In ogni script deve esserci questa scritta)
main()
{
print("\n----------------------------------");
print(" This is a blank GameModeScript");
print("----------------------------------\n");
}
public OnGameModeInit()
{
print("GameModeInit()");
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
printf("OnPlayerRequestClass(%d, %d)", playerid, classid);
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnGameModeExit()
{
print("GameModeExit()");
return 1;
}
public OnPlayerConnect(playerid)
{
printf("OnPlayerConnect(%d)", playerid);
return 1;
}
public OnPlayerDisconnect(playerid)
{
printf("OnPlayerDisconnect(%d)", playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
printf("OnPlayerSpawn(%d)", playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
printf("OnVehicleSpawn(%d)", vehicleid);
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
printf("OnVehicleDeath(%d, %d)", vehicleid, killerid);
return 1;
}
public OnPlayerText(playerid)
{
printf("OnPlayerText(%d)", playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/mycommand", true)==0)
{
/* Do something here */
return 1;
}
return 0;
}
public OnPlayerInfoChange(playerid)
{
printf("OnPlayerInfoChange(%d)");
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate);
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
printf("OnPlayerEnterCheckpoint(%d)", playerid);
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
printf("OnPlayerLeaveCheckpoint(%d)", playerid);
return 1;
}
Invece di copiare tutto il codice, andate nella cartella pawno e aprite il file new.pwn
Prima di iniziare, è utile definire alcune cose, come per esempio i colori
Per fare ciò, in testa a tutto lo script (sopra Main() per intenderci), copiate questo:
#define COLOR_RED 0xAA3333AA
a questo punto abbiamo definito il colore rosso.
altri colori sono:
Grigio: 0xAFAFAFAA
Verde: 0x33AA33AA
Giallo: 0xFFFF00AA
Blu: 0x1111AAFF
Arancione: 0xFF9900AA
Rosa: 0xFF66FFAA
Blu chiaro: 0x33CCFFAA
Rosso scuro: 0x660000AA
Se vogliamo definirli tutti, ecco cosa dovete scrivere:
// Colori
#define COLOR_RED 0xAA3333AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_BLUE 0x1111AAFF
#define COLOR_PINK 0xFF66FFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
La scrittta // Colori non ha nessuno effetto perchè è preceduta dalle due //, ogni scritta preceduta da due // non fa assolutamente nulla. Voi vi chiederete, se non serve a nulla che la mette a fare? La si mette per fare ordine quando lo script
sarà molto più grande.
Molte volte si inserisce una vera e propria barra di separazione tra gli Eventi, come questa:
//---------------------------------------------------------
Cominciamo a parlare degli Eventi, che sono la parte essenziale del codice
Per esempio:
public OnPlayerSpawn(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SendClientMessage(playerid, color, const message[...] )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
public OnPlayerSpawn(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Stile 1:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Stile 2:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Stile 3:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Stile 5:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Stile 6:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
public OnPlayerSpawn(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GameTextForAll(const string[...], time, style )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetTimer(funcname[...], interval, repeating )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetTimer("DefenceWin", 600000, 0);
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Per esempio, creiamo un timer:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetGameModeText(const string[...])
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetGameModeText("Area 51 Break-in");
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetTeamCount(4); // Ammette quattro squadre
AddPlayerClass(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
AddPlayerClass(23,-1404.5,518.15,18.2427,90,28,9000,27,9000,31,9000);
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Perfavore,
Entra
oppure
Registrati
per vedere i Link!
Perfavore,
Entra
oppure
Registrati
per vedere i Link!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
AddStaticVehicle( modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, IDcolor1, IDcolor2 )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Perfavore,
Entra
oppure
Registrati
per vedere i Link!
Perfavore,
Entra
oppure
Registrati
per vedere i Link!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
AddStaticPickup( model, type, Float:X, Float:Y, Float:Z )
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
// Visualizza Nicknames (predefinito)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
// Nascondi Nicknames
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
ShowPlayerMarkers(show)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Show: inserisci 1 se vuoi vedere i segnalini dei giocatori, inserisci 0 se li vuoi nascondere
Esempio:
// Visualizza Seganlini (predefinito)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
// Nascondi Segnalini
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GameModeExit()
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetWorldTime(hour)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetWeaponName(weaponid, const weapon[...], len)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
IsPlayerAdmin(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerTeam(playerid, teamid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerScore(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
public OnPlayerDeath(playerid, killerid, reason)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerPos(playerid, & Float:x, & Float:y, & Float:z)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetPlayerPos(playerid, Float:x, Float:y, Float:z)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerHealth(playerid, & Float:health)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Esempio:
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetPlayerHealth(playerid, Float:health)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
PutPlayerInVehicle(playerid, vehilcleid, seatid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
IsPlayerInVehicle(playerid, vehicleid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerName(playerid, const name[], len)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerColor(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
GetPlayerVehicleID(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
DisablePlayerCheckpoint(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
IsPlayerInCheckpoint(playerid)
Codice:
Perfavore,
Entra
oppure
Registrati
per vedere i codici!
== GUIDA IN COSTRUZIONE ==
Durata Lavoro 2ore e mezza
Fonte:
Perfavore,
Entra
oppure
Registrati
per vedere i Link!
Ultima modifica da un moderatore: