06.11.2014, 14:53
alot of people wanna start scripting but they dont know from where to start , some others just copy without understanding , and other think that by clicking (New File) that they made a cool gm , without even understanding what's written
So i decided to start a full tutorial for teaching at least the basics , cause anyone can predict anything after knowing the scripting basics , so lets start.....
First , if you dont have the file you can download it through http://sa-mp.com/download.php (Note: download the SA-MP 0.3z Windows Server *only if u have windows* if u dont then download SA-MP 0.3z Linux Server (x86) if u have linux)
So now lets start , when u click on (New File) in Pawno , you find this:
probably as a beginner , you'll think that all this does something , but actually it doesnt really do all what u think it does , thats the blank Gamemode , and we're gonna understand it together
lets start with the include
a_samp is an .inc file , it actually acts like a big library in our tutorial , alllllll these functions and stuff are defined inside it , so it actually makes our job way easier , #include is used so we can include any library we need
but what r those lines ?
those lines r called comments , they're important , say you r scripting a very big Gamemode probably there r some stuff which u will forget , so u write // and the sentence to identify this (for urself) those lines r not read by the compiler , but what if i want to make a large comment ? like more than 1 line , here's an easier way
now lets move to this line:
this line is loaded when you add a filterscript to ur .cfg file , you can write (This Filterscript is made by *****) in those lines
lets now look at OnGameModeInit()
SetGameModeText("Blank Script"); this line shows (Blank Script) or whatever you write in samp in the Mode panel
AddPlayerClass , now as u know every skin got its own id , and id 0 is for CJ's skin and as u see there r 1958.3783, 1343.1572, 15.3746, 269.1425 , the 4 shows the floats X,Y,Z and Angle of the skin choosing place
lets move to OnPlayerRequestClass(playerid, classid)
those angles are used to obtain the suitable look on the skins u r choosing
now lets get to the part that all beginners like , OnPlayerCommandText
if() is a condition , like it says if the player do /heal it should make player's health 100
well thats it for now , i'll post more tutorials as soon as possible , hope you understood my tutorial
So i decided to start a full tutorial for teaching at least the basics , cause anyone can predict anything after knowing the scripting basics , so lets start.....
First , if you dont have the file you can download it through http://sa-mp.com/download.php (Note: download the SA-MP 0.3z Windows Server *only if u have windows* if u dont then download SA-MP 0.3z Linux Server (x86) if u have linux)
So now lets start , when u click on (New File) in Pawno , you find this:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(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 OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
lets start with the include
pawn Код:
#include <a_samp>
but what r those lines ?
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
pawn Код:
/*
Here i'm explaining the comment
in separate
lines
*/
pawn Код:
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
lets now look at OnGameModeInit()
pawn Код:
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
AddPlayerClass , now as u know every skin got its own id , and id 0 is for CJ's skin and as u see there r 1958.3783, 1343.1572, 15.3746, 269.1425 , the 4 shows the floats X,Y,Z and Angle of the skin choosing place
lets move to OnPlayerRequestClass(playerid, classid)
pawn Код:
public OnPlayerRequestClass(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;
}
now lets get to the part that all beginners like , OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
well thats it for now , i'll post more tutorials as soon as possible , hope you understood my tutorial