16.01.2014, 13:30
(
Последний раз редактировалось [WA]iRonan; 20.01.2014 в 18:33.
)
iExtras - A easier way to scripting.
Introduction
I have seen many people struggling with options like giving players a certain amount of health or struggling with strings in SendClientMessage, that's the reason I wrote this tutorial.
I am also promoting iExtras a bit as it has a lot of great features saving you a lot of time.
SendClientMessage & Strings
in iExtras there is an easy possibility of bringing 3 lines back to 1, here's a look:
pawn Код:
new astring[128]; // "new" for the string
format(astring,sizeof(astring),"Bad %s! Administrator %s has frozen you",tname,pname); // Adding the Format
SendClientMessage(playerid, COLOR_LIGHTBLUE,astring); // Sending the message.
pawn Код:
SCM(playerid, COLOR_LIGHTBLUE, "Bad %s! Administrator %s has frozen you",tname,pname); // Message with strings
The parameters are: SCM(playerid/killerid, color, text, string);
The Playerid/Killerid is to which person we have to send it, if I kill somebody and I have:
"SCM(killerid, COLOR_WHITE, "Killed somebody, good job %s!", string);"
At this part "%s" keeps %s as there is no "string" defined, lets define one.
pawn Код:
new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1]; // creating the parameter "name"
GetPlayerName(playerid, name, sizeof(name)); // Getting the player name and giving the new above a function.
pawn Код:
SCM(killerid, COLOR_WHITE, "Killed somebody, good job %s!", string);
pawn Код:
SCM(killerid, COLOR_WHITE, "Killed somebody, good job %s!", name);
Код:
Killed somebody, good job iRonan!
Check the include for credits to SCM and other options mentioned in the thread.
Additional items:If you do not want to install the complete include, here is the code for SCM:
pawn Код:
stock SCM(playerid, color, form[], {Float, _}: ...) // Parameters
{
#pragma unused form // Do not remove.
static
tmp[144]
;
new
t1 = playerid,
t2 = color // text Color
;
const
n16 = -16,
size = sizeof tmp << 2
;
#emit const.pri size
#emit stor.s.pri 16
#emit const.pri tmp
#emit stor.s.pri 12
#emit stack 16
#emit sysreq.c format
#emit stack n16
return SendClientMessage(t1, t2, tmp);
}
Parachuting Options
Introduction
iExtras is very good for a parachuting script, so I wrote this addon to the tutorial.
Tutorial
pawn Код:
stock IsPlayerParachuting(playerid)
{
new index = GetPlayerAnimationIndex(playerid)
return (index >= 958 && index <= 962);
}
stock IsPlayerUsingParachute(playerid)
{
new index = GetPlayerAnimationIndex(playerid)
return (index >= 963 && index <= 979);
}
IsPlayerUsingParachute - Detects if the player has the parachute as a weapon.
IsPlayerParachuting - Detects if the player is parachuting (he is falling from the sky with the parachute equiped)
Those can be used for a simple parachuting minigame, which is what we are going to create.
First, the timer. It can be done with OnPlayerUpdate but it is better to detect it per second.
pawn Код:
forward ChuteTimer(playerid);
public ChuteTimer(playerid)
{
// We will be adding options here.
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
SetTimer("ChuteTimer", 1000, 1);
// rest of your code
return 1;
}
pawn Код:
public ChuteTimer(playerid)
{
if(IsPlayerParachuting(playerid)) // Checks if the player is parachuting.
{
SCM(playerid, -1, "%s started parachuting!", PlayerName(playerid)); // Sets up the message, also gets the player's name.
return 1;
}
Required options:
pawn Код:
stock PlayerName(playerid)
{
new name[128+MAX_PLAYER_NAME+128];
GetPlayerName(playerid, name, sizeof(name));
return 1;
}