24.02.2013, 13:47
(
Последний раз редактировалось CreativityLacker; 25.02.2013 в 07:49.
)
Introduction
to many awesome functions
to many awesome functions
Functions/callbacks -
pawn Код:
AddPlayerClassEx(teamid, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
pawn Код:
SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z)
pawn Код:
Valstr(dest[], value, bool:pack=false)
1. AddPlayerClassEx
Syntax -
pawn Код:
(teamid, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
This function works the SAME way as AddPlayerClass, except with an additional 'team_id' parameter.
Usually, what I see is people adding classes OnGameModeInIt and setting team's under OnPlayerRequestClass
Using this function, this -
pawn Код:
public OnGameModeInIt()
{
AddPlayerClass(...);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(classid == 0) return SetPlayerTeam(playerid, 1);
return 1;
}
pawn Код:
public OnGameModeInIt()
{
AddPlayerClassEx(teamid, ...);
return 1;
}
I'd ALSO like to point out, OnPlayerRequestClass is called when player switches class, NOT when he clicks on 'Spawn'.
2. OnPlayerClickMap
Syntax -
This callback is called everytime a player opens the PAUSE >> MAP menu and clicks on a position.Syntax -
pawn Код:
(playerid, Float:fX, Float:fY, Float:fZ)
This callback can be very useful to create innovative features like a GPS or somethin'
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
for(new x=0;x < MAX_PLAYERS; x++)
{
new Float:Pos[3];
GetPlayerPos(x, Pos[0], Pos[1], Pos[2]);
if(Pos[0] == fX && Pos[1] == fY)
{
SendClientMessage(playerid, -1, "[SERVER] You clicked on a player!!!! :D ");
}
break;
}
return 1;
}
3. SetPlayerPosFindZ
Syntax -
This function does EXACTLY what SetPlayerPos does, except -Syntax -
pawn Код:
(playerid, Float:x, Float:y, Float:z)
Player's pos is set to the inserted X
Player's pos is set to the inserted Y
Player's pos IS NOT SET to the inserted Z. Instead, it's set the level wherever ground is available.
In other words, You put in the X and Y, and the server finds the Z. This works a lot like MapAndreas's 2D-Z function, except that nobody has managed to manipulate it to use it to get Z coords without players.
You can use an NPC, set his position to X and Y, and send this data to the server <= Slow but just an idea
4. Valstr
Syntax -
This function does exactly OPPOSITE of strvalSyntax -
pawn Код:
(dest[], value, bool:pack=false)
Strval => Returns the value of a STRING into an integer.
Valstr => Stores an INTEGER into a STRING (Optionally, you can pack it [I'm not here to explain packed and unpacked strings])
Basically, if you have a variable with value 5, you can make this into a STRING without using format
Quote:
SetPlayerPosFindZ is not working serverwise, it is working clientside, thats why it is not possible to get any information out of it.
It is not working with NPCs, because NPCs are no real clients. Furthermore, it is not working very accurate. If the position you are setting a player to is NOT rendered by the client, the player will not get set exactly on the ground (he will spawn too high or underneath the map). You should use the function like this to make it work correctly in every area: Код:
SetPlayerPos(playerid, x, y, z); Set a timer about 100-200ms (or even shorter) to let the client render the zone and THEN use FindZ afterwards: SetPlayerPosFindZ(playerid, x, y, z); You could use the above "script" to make an easy (admin) teleporter for a debug script. Greets |