stock SetMapNameText(command[]) { new string[48]; return format(string,sizeof(string),"mapname %s",command), SendRconCommand(string); }
new
FALSE = 0;
#if !defined SendRconCommandEx
#define SendRconCommandEx(%0,%1) \
do \
{ \
new \
string[64]; \
if(strlen(%0) > 0) \
{ \
format(string, sizeof(string), %0, %1); \
SendRconCommand(string); \
} \
} \
while(FALSE)
#endif
stock SetServerPassword(password[])
{
SendRconCommandEx("password %s", password);
return true;
}
// example:
SetServerPassword("pass1024");
Originally Posted by Don Correlli
pawn Код:
pawn Код:
pawn Код:
pawn Код:
|
Originally Posted by Luka™
Why creating a new variable (FALSE) if you can just type zero?
|
Originally Posted by Don Correlli
Quote:
Well, you can't. If you do it like that, you'll get the warning 205 - (redundant code: constant expression is zero). |
Float:GetPos(playerid,posid)
{
new Float:id[3];
if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid),id[0],id[1],id[2]);else GetPlayerPos(playerid,id[0],id[1],id[2]);
return id[posid-1];
}
GetClosestPlayer(except,Float: radius = 99999.9999)
{
new Float:dis[2],e[2];
e[0] = INVALID_PLAYER_ID;
dis[0] = radius;
for (e[1]=0;e[1]<MAX_PLAYERS;e[1]++)
if(IsPlayerConnected(e[1]) && e[1] != except)
dis[1] = floatsqroot(floatpower(floatabs(floatsub(GetPos(e[1],1),GetPos(except,1))),2)+floatpower(floatabs(floatsub(GetPos(e[1],2),GetPos(except,2))),2)+floatpower(floatabs(floatsub(GetPos(e[1],3),GetPos(except,3))),2));
if(dis[1]< dis[0])
{
dis[0] = dis[1];
e[0] = e[1];
}
return e[0];
}
new
FALSE = 0;
#if !defined SendRconCommandEx
#define SendRconCommandEx(%0,%1) \
do \
{ \
new \
string[64]; \
if(strlen(%0) > 0) \
{ \
format(string, sizeof(string), %0, %1); \
SendRconCommand(string); \
} \
} \
while(FALSE)
#endif
#if !defined CallRemoteFunctionEx
#define CallRemoteFunctionEx(%0,%1,%2,%3,%4) \
do \
{ \
new \
string[64]; \
format(string, sizeof(string), %3, %4); \
CallRemoteFunction(%0, %1, %2, string); \
} \
while(FALSE)
#endif
stock SetServerName(name[])
{
SendRconCommandEx("hostname %s", name);
printf("Setting server name to: \"%s\"", name);
return true;
}
// example:
SetServerName("SA-MP v0.3a server");
stock SetServerGamemode(gamemode[])
{
SendRconCommandEx("gamemodetext %s", gamemode);
printf("Setting server gamemode name to: \"%s\"", gamemode);
return true;
}
// example:
SetServerGamemode("San Andreas Role-Play");
stock SetServerMap(map[])
{
SendRconCommandEx("mapname %s", map);
printf("Setting server map name to: \"%s\"", map);
return true;
}
// example:
SetServerMap("Liberty City");
stock ForcePlayerCommand(playerid, command[])
{
if(IsPlayerConnected(playerid))
{
new
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
CallRemoteFunctionEx("OnPlayerCommandText", "is", playerid, "/%s", command);
printf("Forcing player command: Player: \"%s (%i)\", Command: \"/%s\"", playername, playerid, command);
}
else printf("ERROR: That player is not connected to the server!");
return true;
}
// example:
ForcePlayerCommand(playerid, "/ooc Hello!");
stock ForcePlayerCommand(playerid, command[])
Originally Posted by _Xerxes_
Clever, I've never thought about this before.
|
stock PlayerDirection(playerid)
{
new
Float:ang,
dir[2];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleZAngle(GetPlayerVehicleID(playerid), ang);
else
GetPlayerFacingAngle(playerid, ang);
if (ang > 45 && ang < 135)
format(dir, sizeof(dir), "W");
else if (ang > 135 && ang < 225)
format(dir, sizeof(dir), "S");
else if (ang > 225 && ang < 315)
format(dir, sizeof(dir), "E");
else
format(dir, sizeof(dir), "N");
return dir;
}
Originally Posted by <__Ǝthan__>
Note that the function has been setup backwards because SA-MP's directions are backwards.
|
north (0) | (90)west- -east (270) | south (180)
public DecreaseHealth(playerid, decreaseby)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health-decreaseby);
return 1;
}
Originally Posted by lolumadd [cod5server.tk
]
pawn Код:
|
#define increase 1
#define decrease 2
stock ChangePlayerHealth(playerid, Float:amount, method=increase)
{
new Float:health;
GetPlayerHealth(playerid, health);
switch(method)
{
case increase: SetPlayerHealth(playerid, health+amount);
case decrease: SetPlayerHealth(playerid, health-amount);
}
return true;
}
//increase
dcmd_ihealth(playerid, p[])
return ChangePlayerHealth(playerid, strval(p));
//decrease
dcmd_dhealth(playerid, p[])
return ChangePlayerHealth(playerid, strval(p), decrease);
SetPlayerHealth(playerid, GetPlayerHealth(playerid)-20);
Originally Posted by lrZ^ aka LarzI
pawn Код:
|
stock ChangePlayerHealth(playerid, method=increase, Float:amount)
{
new Float:health;
if(GetPlayerHealth(playerid, health))
{ //EDIT
switch(method)
{
case increase: return SetPlayerHealth(playerid, health+amount);
case decrease: return SetPlayerHealth(playerid, health-amount);
}
}
}
if(ChangePlayerHealth(playerid, increase, strval(tmp))) //it will actually return if SetPlayerHealth succeeded.
{
SendClientMessage(playerid, COLOR_WHAT, "Changing player health successful!");
}//so it's not always returning true.
Originally Posted by lrZ^ aka LarzI
Omg, I can't see why I didn't return the switch case statements, lol.
|