[Tutorial] [TUT] Tutorial about teleports, interiors, giveplayerweapon & drunklevel!
#1

[font=tahoma] Introduction
This is a simple tutorial, which explains you the basic of a simple drunklevel, teleport command, the interior command, and how to give the weapons when they use the command!
*For the rest of the tutorial, go down, there it gives you the tutorial of drunklevel, the interior and playerpos
*If you have tips, or addons on this topic, then add them. If you have comments, or you don't understand things, then ask me


[font=tahoma] Starting
A simple start is just by making a new pawno file. You can on clicking on the 'empty document'-icon.
Now, you must see a list like this:

Code:
// 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;
}
[font=tahoma]*If you want to make this only a teleport pawno-file, then simply add ONLY this:

Code:
// 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;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}
[font=tahoma] Making the command
[font=tahoma]You are a bit closer! Now, we'll go to the command.
The place where it stands '/mycommand' is the command to teleport to that area!
Like, if you want to let them move to 8-Track stadium, then you can add like: '/stadium'
It would look like:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/stadium", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}
[font=tahoma]Now, if the player types /stadium, he goes to nowhere? How does it comes? Because there is no PlayerPosition!

[font=tahoma] PlayerPos
The string 'SetPlayerPos' will teleport the player to the specified location. In this case, we want that he teleports to 8-Track Stadium.
The coordinates from 8-Track Stadium are: '-1395.958,-208/197,1051.170' (Took it from https://sampwiki.blast.hk/wiki/InteriorIDs)
Now, the command would like:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/stadium", cmdtext, true, 10) == 0)
	{
	SetPlayerPos(playerid,-1395.958,-208/197,1051.170); 	// Do something here
	return 1;
	}
	return 0;
}
(The 'playerid' means that it will only teleport the playerid that used the command)
If you want an other Position, then you need to log in as RCON, go to the position, and then use /save
Then you need to go to GTA SA folder, and open 'savedpositions', on the bottom,
you must see a example like this: 'AddPlayerClass(250,1773.1278,-1895.3202,13.5515,269.3578,0,0,0,0,0,0); // '
The meaning of all those coordinates are: 'AddPlayerClass(skinid, Z, Y, X, FaceAngle, Weapon1, Amount1, Weapon2, Amount2, Weapon3, Amount3);


[font=tahoma] Interior
Ok, you are now very close! Now, the interior.
Fine, you got the pos, but if you go ingame, and you press /stadium, you simpely fall!
How does it comes? Because your interior is still ID '0' (outside) (You can check this by using the command /interior)
This will need to change! In this case the 8-Track Stadium interior is '7'.
And, if we put everything together, then it would look like:


Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/stadium", cmdtext, true, 10) == 0)
	{
	SetPlayerPos(playerid,-1395.958,-208/197,1051.170); 	// 
	SetPlayerInterior(playerid, 7);
	return 1;
	}
	return 0;
}
(Just like above, the 'playerid' means that it will only set the new interior for the playerid that used the command)

[font=tahoma] Give player a weapon when he enters a DM area
This code is easy to describe, since its only:
Code:
GivePlayerWeapon(playerid, weaponid, amount);
[font=tahoma]Like, for example, if you want to give him a knife, then the command is:
Code:
GivePlayerWeapon(playerid, 4, 1);
[font=tahoma] DrunkLevel
DrunkLevel means, that if you go to the area, like "/stadium", and you have between the brackets this code:
Code:
SetPlayerDrunkLevel (playerid, 5000);
[font=tahoma]then it means he gets a moving/drunk screen. That is actually simple to explain, but the amount (in this case 5000)
is actually: the higher it is, the wilder the screen moves, and, the lower the amount, the faster he gets sober!
Not hard to explain, isn't it. Anyway, thanks for reading this tutorial! Hope you'll learned something.

[font=tahoma] Credits
MastahServers - The Tutorial
juic.j - Tip
Reply
#2

Nice basic tutorial.

Reply
#3

Looks quite alright unlike some "tutorials" I've already seen here .

Check the language a little (typos, spelling mistakes) and you'll have a very nice, basic tut there.
Reply
#4

Quote:
Originally Posted by juice.j
Looks quite alright unlike some "tutorials" I've already seen here .

Check the language a little (typos, spelling mistakes) and you'll have a very nice, basic tut there.
Questions are always welcome like I said in the top of the topic
Reply
#5

Quote:
Originally Posted by MWF2
Nice basic tutorial.

Thanks, I am also a beginnner in Pawno, but I am understanding it more
Reply
#6

Quote:
Originally Posted by MastahServers
Questions are always welcome like I said in the top of the topic
Just meant you might correct those spelling mistakes and typos you have in there to even improve your tutorial, which is quite nice already
Reply
#7

Tip is added, thanks to juice.j
Reply
#8

Nice tutorial, very useful for beginners.
Reply
#9

Quote:
Originally Posted by ikarus❶❸❸❼
Nice tutorial, very useful for beginners.
Thanks for the nice comment, and I am also a beginner
Reply
#10

i set command to /enter and when i try to entry:



Here are my code:

Code:
     if(strcmp(cmdtext, "/enter", true) == 0)
    {
     SetPlayerPos(playerid,1518.7183,-1452.9669,14.2031); 	//
    	SetPlayerInterior(playerid, 7);
    	SendClientMessage(playerid, COLOR_GREEN,"You entered in test interior");
    	return 1;
    }
Reply
#11

Hello can helpme?!
Reply
#12

thx so much i am a new scripter and it helped me in adding some new teleport commands in my server
Reply
#13

Nice tutorial keep making more.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)