14.01.2014, 10:00
I believe that should be
but nice job, I have a similiar function that fits my script's needs
pawn Код:
if (1 <= index < 1812)
if (1 <= index < 1812)
stock CreateSquareObjectShape(playerid, Float: fDiag, objectsPerLine = 10) {
new
Float: rX[2],
Float: rY[2],
Float: fZ
;
if(GetPlayerPos(playerid, fX[0], fY[0], fZ)) {
new
Float: inc = (fDiag * 0.707 / objectsPerLine),
Float: cos = (fDiag * floatcos(45, degrees)),
Float: sin = (fDiag * floatsin(45, degrees))
;
rX[1] = rX[0] + cos;
rY[1] = rY[0] + sin;
rX[0] -= cos;
rY[0] -= sin;
for(cos = rX[1]; cos > rX[0]; cos -= inc) {
CreateObject(1598, cos, rY[0], fZ, 0, 0, 0);
CreateObject(1598, cos, rY[1], fZ, 0, 0, 0);
}
for(sin = rY[1]; sin > rY[0]; sin -= inc) {
CreateObject(1598, rX[0], sin, fZ, 0, 0, 0);
CreateObject(1598, rX[1], sin, fZ, 0, 0, 0);
}
return true;
}
return false;
}
stock CreateSquareObjectShape(playerid, Float: fDiag, objectsPerLine = 10)
{
new
Float: rX[2],
Float: rY[2],
Float: fZ
;
if(GetPlayerPos(playerid, fX[0], fY[0], fZ))
{
new
Float: inc = (fDiag * 0.707 / objectsPerLine),
Float: cos = (fDiag * floatcos(45, degrees)),
Float: sin = (fDiag * floatsin(45, degrees))
;
rX[1] = rX[0] + cos;
rY[1] = rY[0] + sin;
rX[0] -= cos;
rY[0] -= sin;
for(cos = rX[1]; cos > rX[0]; cos -= inc)
{
#if defined CreateDynamicObject
CreateDynamicObject(1598, cos, rY[0], fZ, 0, 0, 0);
CreateDynamicObject(1598, cos, rY[1], fZ, 0, 0, 0);
#else
CreateObject(1598, cos, rY[0], fZ, 0, 0, 0);
CreateObject(1598, cos, rY[1], fZ, 0, 0, 0);
#endif
}
for(sin = rY[1]; sin > rY[0]; sin -= inc)
{
#if defined CreateDynamicObject
CreateDynamicObject(1598, rX[0], sin, fZ, 0, 0, 0);
CreateDynamicObject(1598, rX[1], sin, fZ, 0, 0, 0);
#else
CreateObject(1598, rX[0], sin, fZ, 0, 0, 0);
CreateObject(1598, rX[1], sin, fZ, 0, 0, 0);
#endif
}
return true;
}
return false;
}
stock MoveObjectEx(objectid, time, Float:x, Float:y, Float:z, Float:rx = -1000.0, Float:ry = -1000.0, Float:rz = -1000.0)
{
if (!IsValidObject(objectid))
return 0;
static
Float:fX,
Float:fY,
Float:fZ,
Float:fDist;
GetObjectPos(objectid, fX, fY, fZ);
fDist = floatsqroot(((fX - x) * (fX - x)) + ((fY - y) * (fY - y)) + ((fZ - z) * (fZ - z)));
MoveObject(objectid, x, y, z, floatdiv(floatsqroot(x + y + z), time / floatmul(fDist, 15)), rx, ry, rz);
return 1;
}
MoveObjectEx(gGateID, 1000, gMoveX, gMoveY, gMoveZ);
stock INI_ReadData(filename[], specifiers[], {Float,_}:...)
{
static
identifiers[32],
argument,
key[32]
;
strcpy(identifiers, specifiers);
for (new i = 0, len = strlen(identifiers); i != len; i ++)
{
if (identifiers[i] != '[')
continue;
strdel(identifiers, i, strfind(identifiers, "]", false, i) + 1);
}
if ((numargs() - 2) / 2 != strlen(identifiers))
{
return printf("** Warning: %d arguments, expecting %d.", numargs() - 2, strlen(identifiers));
}
inline ReadData(name[], value[])
{
for (new i = 2, args = numargs(); i != args; i += 2)
{
va_getstring(key, i);
if (strcmp(name, key, true) != 0)
continue;
switch (identifiers[(argument = i / 2 - 1)])
{
case 'f':
setarg(i + 1, 0, _:floatstr(value));
case 's':
{
new size = strval(specifiers[strfind(specifiers, "[", true, argument) + 1]);
for (new j = 0, len = strlen(value); j < size && j < len; j ++) {
setarg(i + 1, j, value[j]);
}
}
default: {
setarg(i + 1, 0, strval(value));
}
}
break;
}
}
INI_ParseFile(filename, "ReadData");
return 1;
}
// test.ini Money = 10000 Health = 50.0 Score = 2176
new
money,
score,
Float:health;
INI_ReadData("test.ini", "fdd", "Health", health, "Score", score, "Money", money);
new
money,
score,
Float:health,
Float:armor,
str[32];
INI_ReadData("test.ini", "dds[32]ff", "Money", money, "Score", score, "Motto", str, "Health", health, "Armor", armor);
stock DamagePlayer(playerid, Float:damage)
{
static
Float:temp_hp,
Float:temp_ar;
GetPlayerHealth(playerid, temp_hp);
GetPlayerArmour(playerid, temp_ar);
if(temp_ar > 0)
{
if(damage > temp_ar)
{
SetPlayerArmour(playerid, 0.0);
SetPlayerHealth(playerid, floatsub(damage, temp_ar));
}
else if(damage < temp_ar)
{
SetPlayerArmour(playerid, floatsub(temp_ar,damage));
}
}
else if(temp_ar <= 0)
{
if(damage > temp_hp)
{
SetPlayerHealth(playerid, 0.0);
}
else if(damage < temp_hp)
{
SetPlayerHealth(playerid, floatsub(temp_hp,damage));
}
}
return 1;
}
stock damagePlayer(playerid, Float: fDamage) {
new
Float: fHealth,
Float: fArmour
;
GetPlayerHealth(playerid, fHealth);
GetPlayerArmour(playerid, fArmour);
fHealth += fArmour - fDamage;
SetPlayerArmour(playerid, (fHealth > 100.0) ? (fHealth - 100.0) : (0.0));
SetPlayerHealth(playerid, (fHealth > 100.0) ? (100.0) : (fHealth));
}
#define isnrn(%0) (((_:(%0))&0x7F800000) == 0x7F800000)
//...
if(isnrn(1.0/0.0)) printf("ERROR!");
if(isnrn(floatsqroot(-1.0))) printf("ERROR!");
//...
Originally Posted by =>Sandra<=
SendClientMessageToAllEx(exception, color, const message[]) This function sends a message to all players, except for 1 player. (exception) Code: stock SendClientMessageToAllEx(exception, color, const message[]) { for(new i; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(i != exeption) { SendClientMessage(i, color, message); } } } } Need a 'c' in "if(i != ex©eption)" EDIT: Please delete this post when noted. |
stock SetPlayerRandomPos(playerid, Float:position[][3], size = sizeof(position))
{
new rand = random(size);
SetPlayerPos(playerid, position[rand][0], position[rand][1], position[rand][2]);
return rand;
}
stock SetVehicleRandomPos(vehicleid, Float:position[][3], size = sizeof(position))
{
new rand = random(size);
SetVehiclePos(vehicleid, position[rand][0], position[rand][1], position[rand][2]);
return rand;
}
//Returning the randomized value because it can be used for anything else later.
new
Float:RandomPositions[5][3] = { //5 random XYZ positions.
{1614.7770,1162.2877,14.2188},
{2515.5234,-1675.7893,13.8168},
{-1723.2974,-89.6194,3.5547},
{-1980.5894,656.0847,46.5683},
{-1502.7856,824.2550,7.1875}
};
ExampleOnSomething(playerid, vehicleid)
{
SetPlayerRandomPos(playerid, RandomPositions);
SetVehicleRandomPos(vehicleid, RandomPositions);
return 1;
}
SetPlayerMarkerVisibility(playerid, alpha = 0xFF)
return (GetPlayerColor(playerid) & ~0xFF) | clamp(alpha, 0x00, 0xFF);
#define IsNumberOdd(%0) ((%0&0x01):(false)?(true))
#include <a_samp>
new LastWeaponPlayer[MAX_PLAYERS];
new MoneyPlayer[MAX_PLAYERS];
new WeaponPlayer[MAX_PLAYERS][13];
#define GivePlayerWeapon@(%1,%2,%3) WeaponPlayer[%1][GetWeaponSlot(%2)] = %2, GivePlayerWeapon(%1, %2, %3)
#define GivePlayerMoney@(%1,%2) MoneyPlayer[%1] = (GetPlayerMoney(%1)+%2), GivePlayerMoney(%1, %2)
public OnPlayerUpdate(playerid)
{
if(GetPlayerWeapon(playerid) != LastWeaponPlayer[playerid])
{
CallLocalFunction("OnPlayerChangeWeapon", "dii", playerid, GetPlayerWeapon(playerid), LastWeaponPlayer[playerid]);
LastWeaponPlayer[playerid] = GetPlayerWeapon(playerid);
}
if(GetPlayerMoney(playerid) > MoneyPlayer[playerid]) CallLocalFunction("OnPlayerMoneyHack", "dii", playerid, GetPlayerMoney(playerid), MoneyPlayer[playerid]);
return 1;
}
forward OnPlayerChangeWeapon(playerid, newweapon, oldweapon);
public OnPlayerChangeWeapon(playerid, newweapon, oldweapon)
{
static data[2];
GetPlayerWeaponData(playerid, GetWeaponSlot(newweapon), data[0], data[1]);
if(data[0] != WeaponPlayer[playerid][GetWeaponSlot(newweapon)])
{
CallLocalFunction("OnPlayerWeaponHack", "dii", playerid, data[0], WeaponPlayer[playerid][GetWeaponSlot(newweapon)]);
}
return 1;
}
stock GetWeaponSlot(weaponid)
{
switch(weaponid)
{
case 0, 1: return 0;
case 2 .. 9: return 1;
case 22 .. 24: return 2;
case 25 .. 27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35 .. 38: return 7;
case 16 .. 19, 39: return 8;
case 41 .. 43: return 9;
case 10 .. 15: return 10;
case 44 .. 46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}
forward OnPlayerMoneyHack(playerid, hackmoney, oldmoney);
forward OnPlayerWeaponHack(playerid, hackweapon, realweapon);
public OnPlayerSpawn(playerid)
{
// Here if you assign weapon...
LastWeaponPlayer[playerid] = lastweapon; // 'lastweapon' Would refer to the last one ID of weapon that we assign in this callback.
return 1;
}
stock IsPlayerPingKick(playerid,maxping){
if(GetPlayerPing(playerid) > maxping){
Kick(playerid);
}return true;}
IsPlayerPingKick(playerid, 300);
IsPlayerPingKick
pawn Code:
pawn Code:
|