i know that but i don't find but if i remove IsPlayerLAdmin he will give only 1 error because don't know the IsPlayerLAdmin(playerid) function and this is not a problem but i don't know how to fix that dutils errors if JBC_SetPlayerMoney doesn't exist in dutils... and if i don't what function is wrong..
he also give me error if using JunkBUster + dini
here is the JunkBuster include
pawn Код:
/*
+---------------------------------------------------------------------------+
¦ JunkBuster Anti-Cheat ¦
¦ by ¦
¦ Double-O-Seven ¦
¦ ¦
¦ This is the JunkBuster Client include. Use it in all of your scripts! ¦
¦ IMPORTANT: ¦
¦ JunkBuster filterscripts must get loaded before all other scripts! ¦
¦ Be careful: You must run the JunkBuster filterscript or none of the ¦
¦ functions below will work! ¦
+---------------------------------------------------------------------------+
*/
#if defined _JB_included
#endinput
#endif
#define _JB_included
#include <a_samp>
//==============================================================================
// For better compatibility for example with LuxAdmin.
#if !defined USE_NEW_JB_FUNCTIONS
#define USE_NEW_JB_FUNCTIONS true // Set to false if you don't want to use them or if you are using LuxAdmin
#endif
//==============================================================================
#define PUBLIC:%0(%1) forward %0(%1); \
public %0(%1)
// Doesn't work for functions with arrays as arguments or no arguments, also doesn't work for functions with default arguments.
// But it make some things easier.
#define EXTERN:%0<%1>(%2) \
stock JBC_%0 (%2) \
return CallRemoteFunction ("JB_"#%0, #%1, %2)
// Make the whole sh*t consistent.
#define EXTERN2:%0(%1) \
stock JBC_%0(%1)
#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
/*
native GetPlayerFPS(playerid);
native GetPlayerSpeed(playerid,get3d=false);
native AntiBugKill(playerid);
native CheckText(playerid,text[]);
native GodModeCheck(playerid);
native AllowWeaponForPlayer(playerid,weaponid);
native ForbidWeaponForPlayer(playerid,weaponid,antibugkill);
native ResetForbiddenWeaponsForPlayer(playerid,antibugkill);
native IsForbiddenWeapon(weaponid);
native IsForbiddenWeaponForPlayer(playerid,weaponid);
native AddWeaponPickup(Float:x,Float:y,Float:z,weaponid,ammo,worldid);
native PlayerReportPlayer(playerid,reporterid,report[]);
native SetPlayerSpawnKillProtected(playerid,set);
native JunkBusterChrome(playerid,comment[]="No comment");
native SetPlayerMoney(playerid,money);
native IpBanCheck(playerid);
native BanIp(ipstring[]);
native UnbanIp(ipstring[]);
native AddNameToBlacklist(name[]);
native RemoveNameFromBlacklist(name[]);
native AddPlayerToBlacklist(playerid);
native IsPlayerOnBlacklist(playerid);
native AddNameToWhitelist(name[]);
native RemoveNameFromWhitelist(name[]);
native AddPlayerToWhitelist(playerid);
native IsPlayerOnWhitelist(playerid);
native TempBanCheck(playerid);
native TempBan(playerid,days,reason[]);
native DeleteTempBan(name[]);
native SetJBVar(var[],value);
native GetJBVar(var[]);
*/
//==============================================================================
/*
You have to add these callbacks yourself and you can do with what you want:
BUT: You don't have to use these callbacks at all... I just thought they can be helpful for whatever, I don't know.
*/
forward OnJunkBusterBan (playerid, reason []);
forward OnJunkBusterKick (playerid, reason []);
forward OnJunkBusterReport (playerid, reason [], details []);
//You SHOULD add this function to your adminscript etc. to guarantee admin immunity and correct working reports!
forward IsPlayerAdminCall (playerid);
/*
Put for example this into your gamemode (example for Godfather):
public IsPlayerAdminCall (playerid)
return (PlayerInfo [playerid] [pAdmin] >= 1);
AGAIN: This is an example and may only work for the Godfather script.
You have to create a function which fits to your OWN gamemode!
*/
//==============================================================================
//Don't let noobs crash your server by abusing the % symbol in inputtext.
public OnDialogResponse (playerid, dialogid, response, listitem, inputtext [])
{
new len = strlen (inputtext);
for (new i = 0; i < len; ++i)
if (inputtext [i] == '%')
inputtext [i] = '#';
if (!len)
return CallLocalFunction ("JBC_OnDialogResponse", "iiiis", playerid, dialogid, response, listitem, "\1");
return CallLocalFunction ("JBC_OnDialogResponse", "iiiis", playerid, dialogid, response, listitem, inputtext);
}
//OnDialogResponse
#if defined _ALS_OnDialogResponse
#undef OnDialogResponse
#else
#define _ALS_OnDialogResponse
#endif
#define OnDialogResponse JBC_OnDialogResponse
forward JBC_OnDialogResponse (playerid, dialogid, response, listitem, inputtext []);
//==============================================================================
// EXISTING functions which JunkBuster MUST overwrite!
EXTERN:PutPlayerInVehicle <iii>(playerid, vehicleid, seatid);
EXTERN:GivePlayerMoney <ii>(playerid, amount);
EXTERN:ResetPlayerMoney <i>(playerid);
EXTERN:GetPlayerMoney <i>(playerid);
EXTERN:SetPlayerPos <ifff>(playerid, Float: x, Float: y, Float: z);
EXTERN:SetPlayerPosFindZ <ifff>(playerid, Float: x, Float: y, Float: z);
EXTERN:SetVehiclePos <ifff>(vehicleid, Float: x, Float: y, Float: z);
EXTERN:SetVehicleVelocity <ifff>(vehicleid, Float: x, Float: y, Float: z);
EXTERN:GivePlayerWeapon <iii>(playerid, weaponid, ammo);
EXTERN:ResetPlayerWeapons <i>(playerid);
EXTERN:SetPlayerHealth <df>(playerid, Float: health);
EXTERN:SetPlayerArmour <df>(playerid, Float: armour);
EXTERN:SetVehicleHealth <df>(vehicleid, Float: health);
EXTERN:TogglePlayerControllable <ii>(playerid, toggle);
EXTERN:TogglePlayerSpectating <ii>(playerid, toggle);
EXTERN:SetPlayerSpecialAction <ii>(playerid, actionid);
EXTERN:SetPlayerRaceCheckpoint <iifffffff>(playerid, type, Float: x, Float: y, Float: z, Float: nextx, Float: nexty, Float: nextz, Float: size);
EXTERN:AddPlayerClass <iffffiiiiii>(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
EXTERN:AddPlayerClassEx <iiffffiiiiii>(teamid, modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
EXTERN:SetSpawnInfo <iiiffffiiiiii>(playerid, team, skin, Float: x, Float: y, Float: z, Float: rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
EXTERN:DestroyPickup <i>(pickupid);
EXTERN:RepairVehicle <i>(vehicleid);
EXTERN:CreateVehicle <iffffiii>(vehicletype, Float:x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay);
EXTERN:AddStaticVehicle <iffffii>(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2);
EXTERN:AddStaticVehicleEx <iffffiii>(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2, respawn_delay);
EXTERN:AddVehicleComponent <ii>(vehicleid, componentid);
EXTERN:RemoveVehicleComponent <ii>(vehicleid, componentid);
EXTERN2:AddStaticPickup (model, type, Float: x, Float: y, Float: z, virtualworld = 0)
return CallRemoteFunction ("JB_AddStaticPickup", "iifffi", model, type, x, y, z, virtualworld);
EXTERN2:CreatePickup (model, type, Float: x, Float: y, Float: z, virtualworld = 0)
return CallRemoteFunction ("JB_CreatePickup", "iifffi", model, type, x, y, z, virtualworld);
EXTERN2:UsePlayerPedAnims ()
{
CallRemoteFunction ("OnUsePlayerPedAnims", "");
return UsePlayerPedAnims ();
}
EXTERN2:SetPlayerName (playerid, name [])
{
if (SetPlayerName (playerid, name))
{
CallRemoteFunction ("OnSetPlayerName", "is", playerid, name);
return 1;
}
return 0;
}
//NEW functions given to you by JunkBuster!
#if USE_NEW_JB_FUNCTIONS == true
EXTERN:GetPlayerFPS <i>(playerid);
EXTERN:AntiBugKill <i>(playerid);//This basically respawns the player.
EXTERN:GodModeCheck <i>(playerid);
EXTERN:AllowWeaponForPlayer <ii>(playerid, weaponid);
EXTERN:ForbidWeaponForPlayer <iii>(playerid, weaponid, antibugkill);
EXTERN:IsForbiddenWeapon <i>(weaponid);
EXTERN:IsForbiddenWeaponForPlayer <ii>(playerid, weaponid);
EXTERN:SetPlayerSpawnKillProtected <ii>(playerid, set);
EXTERN:SetPlayerMoney <ii>(playerid, money);
EXTERN2:GetPlayerSpeed (playerid, get3d = false)
return CallRemoteFunction ("JB_GetPlayerSpeed", "ii", playerid, get3d);
EXTERN2:CheckText (playerid, text [])//return 1: something forbidden found, return 0: everything OK!
return (!isnull (text) ? CallRemoteFunction ("CheckText", "is", playerid, text) : 0);
EXTERN2:ResetFWeaponsForPlayer (playerid, antibugkill)
return CallRemoteFunction ("ResetForbiddenWeaponsForPlayer", "ii", playerid, antibugkill);
EXTERN2:AddWeaponPickup (Float: x, Float: y, Float: z, weaponid, ammo, worldid = 0)
return CallRemoteFunction ("AddWeaponPickup", "fffiii", x, y, z, weaponid, ammo, worldid);
EXTERN2:JunkBusterChrome (playerid, comment [] = "No comment")
return CallRemoteFunction ("JunkBusterChrome", "is", playerid, isnull (comment) ? ("No comment") : comment);
EXTERN2:SetJBVar (var [], value)
return (!isnull (var) ? CallRemoteFunction ("SetJBVar", "si", var, value) : 0);
EXTERN2:GetJBVar (var [])
return (!isnull (var) ? CallRemoteFunction ("GetJBVar", "s", var) : -1);
EXTERN2:IpBanCheck (playerid)
return CallRemoteFunction ("IpBanCheck", "i", playerid);
EXTERN2:BanIp (ipstring [])
return (!isnull (ipstring) ? CallRemoteFunction ("BanIp", "s", ipstring) : 0);
EXTERN2:UnbanIp (ipstring [])
return (!isnull (ipstring) ? CallRemoteFunction ("UnbanIp", "s", ipstring) : 0);
EXTERN2:AddNameToBlacklist (name [])
return (!isnull (name) ? CallRemoteFunction ("AddNameToBlacklist", "s", name) : 0);
EXTERN2:RemoveNameFromBlacklist (name [])
return (!isnull (name) ? CallRemoteFunction ("RemoveNameFromBlacklist", "s", name) : 0);
EXTERN2:AddPlayerToBlacklist (playerid)
return CallRemoteFunction ("AddPlayerToBlacklist", "i", playerid);
EXTERN2:IsPlayerOnBlacklist (playerid)
return CallRemoteFunction ("IsPlayerOnBlacklist", "i", playerid);
EXTERN2:AddNameToWhitelist (name [])
return (!isnull (name) ? CallRemoteFunction ("AddNameToWhitelist", "s", name) : 0);
EXTERN2:RemoveNameFromWhitelist (name [])
return (!isnull (name) ? CallRemoteFunction ("RemoveNameFromWhitelist", "s", name) : 0);
EXTERN2:AddPlayerToWhitelist (playerid)
return CallRemoteFunction ("AddPlayerToWhitelist", "i", playerid);
EXTERN2:IsPlayerOnWhitelist (playerid)
return CallRemoteFunction ("IsPlayerOnWhitelist", "i", playerid);
EXTERN2:TempBanCheck (playerid)
return CallRemoteFunction ("TempBanCheck", "i", playerid);
EXTERN2:TempBan (playerid, days, reason [])
return CallRemoteFunction ("TempBan", "iis", playerid, days, isnull (reason) ? ("No reason") : reason);
EXTERN2:DeleteTempBan (name [])
return (!isnull (name) ? CallRemoteFunction ("DeleteTempBan", "s", name) : 0);
/*
Use PlayerReportPlayer (playerid, reporterid, report []) to let JunkBuster know
that a player has reported another player.
DESCRIPTION:
- 'playerid' is the ID of the player who has been reported. Maybe a cheater? Let it JunkBuster know!
- 'reporterid' is the ID of the player who has reported the other player.
- 'report' is the report. If it contains 'god' or 'mod' JunkBuster will check the 'playerid' for godmode.
IMPORTANT:
JunkBuster searches for keywords "god" and "health". And if found the reported player will get checked for godmode.
However JunkBuster will not react on every report. A player can't get spammed with GodModeCheck.
Spamming GodModeCheck on a player can end up with a kick/ban even when the player is innoncent. (Tested)
*/
stock PlayerReportPlayer (playerid, reporterid, report [])
{
if (IsPlayerConnected (playerid) && IsPlayerConnected (reporterid) && !isnull (report))
return CallRemoteFunction ("OnPlayerReport", "iis", playerid, reporterid, report);
return 0;
}
#endif
//==============================================================================
#if defined _ALS_PutPlayerInVehicle
#undef PutPlayerInVehicle
#else
#define _ALS_PutPlayerInVehicle
#endif
#define PutPlayerInVehicle JBC_PutPlayerInVehicle
#if defined _ALS_GivePlayerMoney
#undef GivePlayerMoney
#else
#define _ALS_GivePlayerMoney
#endif
#define GivePlayerMoney JBC_GivePlayerMoney
#if defined _ALS_ResetPlayerMoney
#undef ResetPlayerMoney
#else
#define _ALS_ResetPlayerMoney
#endif
#define ResetPlayerMoney JBC_ResetPlayerMoney
#if defined _ALS_GetPlayerMoney
#undef GetPlayerMoney
#else
#define _ALS_GetPlayerMoney
#endif
#define GetPlayerMoney JBC_GetPlayerMoney
#if defined _ALS_SetPlayerPos
#undef SetPlayerPos
#else
#define _ALS_SetPlayerPos
#endif
#define SetPlayerPos JBC_SetPlayerPos
#if defined _ALS_SetPlayerPosFindZ
#undef SetPlayerPosFindZ
#else
#define _ALS_SetPlayerPosFindZ
#endif
#define SetPlayerPosFindZ JBC_SetPlayerPosFindZ
#if defined _ALS_SetVehiclePos
#undef SetVehiclePos
#else
#define _ALS_SetVehiclePos
#endif
#define SetVehiclePos JBC_SetVehiclePos
#if defined _ALS_GivePlayerWeapon
#undef GivePlayerWeapon
#else
#define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon JBC_GivePlayerWeapon
#if defined _ALS_ResetPlayerWeapons
#undef ResetPlayerWeapons
#else
#define _ALS_ResetPlayerWeapons
#endif
#define ResetPlayerWeapons JBC_ResetPlayerWeapons
#if defined _ALS_SetPlayerHealth
#undef SetPlayerHealth
#else
#define _ALS_SetPlayerHealth
#endif
#define SetPlayerHealth JBC_SetPlayerHealth
#if defined _ALS_SetPlayerArmour
#undef SetPlayerArmour
#else
#define _ALS_SetPlayerArmour
#endif
#define SetPlayerArmour JBC_SetPlayerArmour
#if defined _ALS_SetVehicleHealth
#undef SetVehicleHealth
#else
#define _ALS_SetVehicleHealth
#endif
#define SetVehicleHealth JBC_SetVehicleHealth
#if defined _ALS_TogglePlayerControllable
#undef TogglePlayerControllable
#else
#define _ALS_TogglePlayerControllable
#endif
#define TogglePlayerControllable JBC_TogglePlayerControllable
#if defined _ALS_TogglePlayerSpectating
#undef TogglePlayerSpectating
#else
#define _ALS_TogglePlayerSpectating
#endif
#define TogglePlayerSpectating JBC_TogglePlayerSpectating
#if defined _ALS_SetVehicleVelocity
#undef SetVehicleVelocity
#else
#define _ALS_SetVehicleVelocity
#endif
#define SetVehicleVelocity JBC_SetVehicleVelocity
#if defined _ALS_SetPlayerSpecialAction
#undef SetPlayerSpecialAction
#else
#define _ALS_SetPlayerSpecialAction
#endif
#define SetPlayerSpecialAction JBC_SetPlayerSpecialAction
#if defined _ALS_SetPlayerRaceCheckpoint
#undef SetPlayerRaceCheckpoint
#else
#define _ALS_SetPlayerRaceCheckpoint
#endif
#define SetPlayerRaceCheckpoint JBC_SetPlayerRaceCheckpoint
#if defined _ALS_AddStaticPickup
#undef AddStaticPickup
#else
#define _ALS_AddStaticPickup
#endif
#define AddStaticPickup JBC_AddStaticPickup
#if defined _ALS_CreatePickup
#undef CreatePickup
#else
#define _ALS_CreatePickup
#endif
#define CreatePickup JBC_CreatePickup
#if defined _ALS_DestroyPickup
#undef DestroyPickup
#else
#define _ALS_DestroyPickup
#endif
#define DestroyPickup JBC_DestroyPickup
#if defined _ALS_AddPlayerClass
#undef AddPlayerClass
#else
#define _ALS_AddPlayerClass
#endif
#define AddPlayerClass JBC_AddPlayerClass
#if defined _ALS_AddPlayerClassEx
#undef AddPlayerClassEx
#else
#define _ALS_AddPlayerClassEx
#endif
#define AddPlayerClassEx JBC_AddPlayerClassEx
#if defined _ALS_SetSpawnInfo
#undef SetSpawnInfo
#else
#define _ALS_SetSpawnInfo
#endif
#define SetSpawnInfo JBC_SetSpawnInfo
#if defined _ALS_UsePlayerPedAnims
#undef UsePlayerPedAnims
#else
#define _ALS_UsePlayerPedAnims
#endif
#define UsePlayerPedAnims JBC_UsePlayerPedAnims
#if defined _ALS_SetPlayerName
#undef SetPlayerName
#else
#define _ALS_SetPlayerName
#endif
#define SetPlayerName JBC_SetPlayerName
#if defined _ALS_RepairVehicle
#undef RepairVehicle
#else
#define _ALS_RepairVehicle
#endif
#define RepairVehicle JBC_RepairVehicle
#if defined _ALS_CreateVehicle
#undef CreateVehicle
#else
#define _ALS_CreateVehicle
#endif
#define CreateVehicle JBC_CreateVehicle
#if defined _ALS_AddStaticVehicle
#undef AddStaticVehicle
#else
#define _ALS_AddStaticVehicle
#endif
#define AddStaticVehicle JBC_AddStaticVehicle
#if defined _ALS_AddStaticVehicleEx
#undef AddStaticVehicleEx
#else
#define _ALS_AddStaticVehicleEx
#endif
#define AddStaticVehicleEx JBC_AddStaticVehicleEx
#if defined _ALS_AddVehicleComponent
#undef AddVehicleComponent
#else
#define _ALS_AddVehicleComponent
#endif
#define AddVehicleComponent JBC_AddVehicleComponent
#if defined _ALS_RemoveVehicleComponent
#undef RemoveVehicleComponent
#else
#define _ALS_RemoveVehicleComponent
#endif
#define RemoveVehicleComponent JBC_RemoveVehicleComponent
#if USE_NEW_JB_FUNCTIONS == true
#define GetPlayerFPS JBC_GetPlayerFPS
#define GetPlayerSpeed JBC_GetPlayerSpeed
#define AntiBugKill JBC_AntiBugKill
#define CheckText JBC_CheckText
#define GodModeCheck JBC_GodModeCheck
#define AllowWeaponForPlayer JBC_AllowWeaponForPlayer
#define ForbidWeaponForPlayer JBC_ForbidWeaponForPlayer
#define ResetForbiddenWeaponsForPlayer JBC_ResetFWeaponsForPlayer
#define IsForbiddenWeapon JBC_IsForbiddenWeapon
#define IsForbiddenWeaponForPlayer JBC_IsForbiddenWeaponForPlayer
#define AddWeaponPickup JBC_AddWeaponPickup
#define SetPlayerSpawnKillProtected JBC_SetPlayerSpawnKillProtected
#define JunkBusterChrome JBC_Chrome
#define SetJBVar JBC_SetJBVar
#define GetJBVar JBC_GetJBVar
#define SetPlayerMoney JBC_SetPlayerMoney
#define IpBanCheck JBC_IpBanCheck
#define BanIp JBC_BanIp
#define UnbanIp JBC_UnbanIp
#define AddNameToBlacklist JBC_AddNameToBlacklist
#define RemoveNameFromBlacklist JBC_RemoteNameFromBlacklist
#define AddPlayerToBlacklist JBC_AddNameToBlacklist
#define IsPlayerOnBlacklist JBC_IsPlayerOnBlacklist
#define AddNameToWhitelist JBC_AddNameToWhitelist
#define RemoveNameFromWhitelist JBC_RemoteNameFromWhitelist
#define AddPlayerToWhitelist JBC_AddNameToWhitelist
#define IsPlayerOnWhitelist JBC_IsPlayerOnWhitelist
#define TempBanCheck JBC_TempBanCheck
#define TempBan JBC_TempBan
#define DeleteTempBan JBC_DeleteTempBan
#endif
Dini include
pawn Код:
/*
* Dini 1.5.1
* © Copyright 2006 by DracoBlue
*
* @author : DracoBlue (http://dracoblue.com)
* @date : 13th May 2006
* @update : 3rd June 2007
* @require : DUtils 1.8
*
* This file is provided as is (no warranties).
*
* Feel free to use it, a little message in
* about box is honouring thing, isn't it?
*
*/#if defined _dini_included #endinput#endif#define _dini_included#pragma library dutils#include <dutils>stock dini_Exists
(filename
[]) { if (fexist(filename
)) return true;
return false;
}stock dini_Remove
(filename
[]) { if (!fexist(filename
)) return false;
fremove(filename
);
return true;
}stock dini_Create
(filename
[]) { new File:fhnd;
if (fexist(filename
)) return false;
fhnd
=fopen(filename,io_write
);
fclose(fhnd
);
return true;
}stock dini_PRIVATE_ExtractKey
(line
[]) { new tmp
[MAX_STRING
];
tmp
[0]=0;
if (strfind(line,
"=",true
)==-1) return tmp;
set
(tmp,strlower
(ret_memcpy
(line,
0,
strfind(line,
"=",true
))));
return tmp;
}stock dini_PRIVATE_ExtractValue
(line
[]) { new tmp
[MAX_STRING
];
tmp
[0]=0;
if (strfind(line,
"=",true
)==-1) { return tmp;
} set
(tmp,ret_memcpy
(line,
strfind(line,
"=",true
)+1,
strlen(line
)));
return tmp;
}stock dini_Set
(filename
[],key
[],value
[]) { new File:fohnd,
File:fwhnd;
new bool:wasset
=false;
new tmpres
[MAX_STRING
];
if (key
[0]==0) return false;
/* If we have no sign in key, it can't be set*/ format(tmpres,
sizeof(tmpres
),
"%s.part",filename
);
fohnd
=fopen(filename,io_read
);
if (!fohnd
) return false;
fremove(tmpres
);
fwhnd
=fopen(tmpres,io_write
);
// if (!fwhnd) return false; while (fread(fohnd,tmpres
)) { StripNewLine
(tmpres
);
if ((!wasset
)&&(equal
(dini_PRIVATE_ExtractKey
(tmpres
),key,true
))) { /* We've got what needs to be replaced! */ format(tmpres,
sizeof(tmpres
),
"%s=%s",key,value
);
wasset
=true;
} fwrite(fwhnd,tmpres
);
fwrite(fwhnd,
"\r\n");
} if (!wasset
) { format(tmpres,
sizeof(tmpres
),
"%s=%s",key,value
);
fwrite(fwhnd,tmpres
);
fwrite(fwhnd,
"\r\n");
} fclose(fohnd
);
fclose(fwhnd
);
format(tmpres,
sizeof(tmpres
),
"%s.part",filename
);
if (fcopytextfile
(tmpres,filename
)) { return fremove(tmpres
);
} return false;
}stock dini_IntSet
(filename
[],key
[],value
) { new valuestring
[MAX_STRING
];
format(valuestring,
sizeof(valuestring
),
"%d",value
);
return dini_Set
(filename,key,valuestring
);
}stock dini_Int
(filename
[],key
[]) { return strval(dini_Get
(filename,key
));
}stock dini_FloatSet
(filename
[],key
[],
Float:value
) { new valuestring
[MAX_STRING
];
format(valuestring,
sizeof(valuestring
),
"%f",value
);
return dini_Set
(filename,key,valuestring
);
}stock Float:dini_Float
(filename
[],key
[]) { return floatstr(dini_Get
(filename,key
));
}stock dini_Bool
(filename
[],key
[]) { return strval(dini_Get
(filename,key
));
}stock dini_BoolSet
(filename
[],key
[],value
) { new valuestring
[MAX_STRING
];
format(valuestring,
sizeof(valuestring
),
"%d",value
);
return dini_Set
(filename,key,valuestring
);
}stock dini_Unset
(filename
[],key
[]) { new File:fohnd,
File:fwhnd;
new tmpres
[MAX_STRING
];
format(tmpres,
sizeof(tmpres
),
"%s.part",filename
);
fohnd
=fopen(filename,io_read
);
if (!fohnd
) return false;
fremove(tmpres
);
fwhnd
=fopen(tmpres,io_write
);
// if (!fwhnd) return false; while (fread(fohnd,tmpres
)) { StripNewLine
(tmpres
);
if (equal
(dini_PRIVATE_ExtractKey
(tmpres
),key,true
)) { /* We've got what needs to be removed! */ } else { format(tmpres,
sizeof(tmpres
),
"%s",tmpres
);
fwrite(fwhnd,tmpres
);
fwrite(fwhnd,
"\r\n");
} } fclose(fohnd
);
fclose(fwhnd
);
format(tmpres,
sizeof(tmpres
),
"%s.part",filename
);
if (fcopytextfile
(tmpres,filename
)) { return fremove(tmpres
);
} return false;
}stock dini_Get
(filename
[],key
[]) { new File:fohnd;
new tmpres
[MAX_STRING
];
new tmpres2
[MAX_STRING
];
tmpres
[0]=0;
fohnd
=fopen(filename,io_read
);
if (!fohnd
) return tmpres;
while (fread(fohnd,tmpres
)) { StripNewLine
(tmpres
);
if (equal
(dini_PRIVATE_ExtractKey
(tmpres
),key,true
)) { /* We've got what we need */ tmpres2
[0]=0;
strcat(tmpres2,dini_PRIVATE_ExtractValue
(tmpres
));
fclose(fohnd
);
return tmpres2;
} } fclose(fohnd
);
return tmpres;
}stock dini_Isset
(filename
[],key
[]) { new File:fohnd;
new tmpres
[MAX_STRING
];
fohnd
=fopen(filename,io_read
);
if (!fohnd
) return false;
while (fread(fohnd,tmpres
)) { StripNewLine
(tmpres
);
if (equal
(dini_PRIVATE_ExtractKey
(tmpres
),key,true
)) { /* We've got what we need */ fclose(fohnd
);
return true;
} } fclose(fohnd
);
return false;
}
Dutils include
pawn Код:
/*
* DUtils functions 1.10
* © Copyright 2006-2007 by DracoBlue
*
* @author : DracoBlue (http://dracoblue.com)
* @date : 8th April 2006
* @update : 12th July 2007
*
* This file is provided as is (no warranties).
*
*/#if defined _dutils_included #endinput#endif#define _dutils_included#pragma library dutils#define MAX_STRING 255new PRIVATE_Last_Money
[MAX_PLAYERS
];
/*
* First version released by mike, this one created by DracoBlue
* Has also a fix to use "-" and "+" in the beginning of the number.
*/stock isNumeric
(const string
[]) { new length
=strlen(string
);
if (length
==0) return false;
for (new i
= 0; i
< length; i
++) { if ( (string
[i
] > '9' || string
[i
] < '0' && string
[i
]!='-' && string
[i
]!='+') // Not a number,'+' or '-' ||
(string
[i
]=='-' && i
!=0) // A '-' but not at first. ||
(string
[i
]=='+' && i
!=0) // A '+' but not at first. ) return false;
} if (length
==1 && (string
[0]=='-' || string
[0]=='+')) return false;
return true;
}/*
* Originally created by mabako, tuned by DracoBlue
*/stock mktime
(hour,minute,second,day,month,year
) { new timestamp2;
timestamp2
= second
+ (minute
* 60) + (hour
* 3600);
new days_of_month
[12];
if ( ((year
% 4 == 0) && (year
% 100 != 0)) ||
(year
% 400 == 0) ) { days_of_month
= {31,
29,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31};
// Schaltjahr } else { days_of_month
= {31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31};
// keins } new days_this_year
= 0;
days_this_year
= day;
if(month
> 1) { // No January Calculation, because its always the 0 past months for(new i
=0; i
<month
-1;i
++) { days_this_year
+= days_of_month
[i
];
} } timestamp2
+= days_this_year
* 86400;
for(new j
=1970;j
<year;j
++) { timestamp2
+= 31536000;
if ( ((year
% 4 == 0) && (year
% 100 != 0)) ||
(year
% 400 == 0) ) timestamp2
+= 86400;
// Schaltjahr + 1 Tag } return timestamp2;
}/**
* Return if a Email is valid or not
* @param value
*/stock ValidEmail
(email
[]) { new len
=strlen(email
);
new cstate
=0;
new i;
for(i
=0;i
<len;i
++) { if ((cstate
==0 || cstate
==1) && (email
[i
]>='A' && email
[i
]<='Z') ||
(email
[i
]>='a' && email
[i
]<='z') ||
(email
[i
]=='.') ||
(email
[i
]=='-') ||
(email
[i
]=='_')) { } else { // Ok no A..Z,a..z,_,.,- if ((cstate
==0) &&(email
[i
]=='@')) { // its an @ after the name, ok state=1; cstate
=1;
} else { // Its stuff which is not allowed return false;
} } } if (cstate
<1) return false;
if (len
<6) return false;
// A toplevel domain has only 3 to 4 signs :-) if ((email
[len
-3]=='.') ||
(email
[len
-4]=='.') ||
(email
[len
-5]=='.')) return true;
return false;
}/**
* Return a timestamp
*/stock Time
() { new hour,minute,second;
new year, month,day;
gettime(hour, minute, second
);
getdate(year, month, day
);
return mktime
(hour,minute,second,day,month,year
);
}/**
* Return a timestamp
*/stock Now
() { new hour,minute,second;
new year, month,day;
gettime(hour, minute, second
);
getdate(year, month, day
);
return mktime
(hour,minute,second,day,month,year
);
}/**
* Return the value of an hex-string
* @param string
*/stock HexToInt
(string
[]) { if (string
[0]==0) return 0;
new i;
new cur
=1;
new res
=0;
for (i
=strlen(string
);i
>0;i
--) { if (string
[i
-1]<58) res
=res
+cur
*(string
[i
-1]-48);
else res
=res
+cur
*(string
[i
-1]-65+10);
cur
=cur
*16;
} return res;
}/**
* Return the int as string
* @param number
*/stock IntToHex
(number
){ new m
=1;
new depth
=0;
while (number
>=m
) { m
= m
*16;
depth
++;
} depth
--;
new str
[MAX_STRING
];
for (new i
= depth; i
>= 0; i
--) { str
[i
] = ( number
& 0x0F
) + 0x30;
// + (tmp > 9 ? 0x07 : 0x00) str
[i
] += (str
[i
] > '9') ? 0x07
: 0x00;
number
>>= 4;
} str
[8] = '\0';
return str;
}/**
* Return the string as int
* @param string
*/stock StrToInt
(string
[]) { return strval(string
);
}/**
* Return the value as string
* @param value
*/stock IntToStr
(value
) { new tmp
[MAX_STRING
];
valstr(tmp, value
);
return tmp;
}/**
* Return the truncated value
* @param Float:value
*/stock trunc
(Float:value
) { return floatround(value,floatround_floor
);
}/**
* Sets money for player
* @param playerid
* howmuch
*/stock SetPlayerMoney
(playerid,howmuch
) { PRIVATE_Last_Money
[playerid
]=howmuch;
GivePlayerMoney
(playerid,howmuch
-GetPlayerMoney
(playerid
));
}/**
* Copies a file (Source file won't be deleted!)
* @param oldname
* newname
* @requires WINDOWS
*/stock fcopy
(oldname
[],newname
[]) { new File:ohnd,
File:nhnd;
if (!fexist(oldname
)) return false;
ohnd
=fopen(oldname,io_read
);
nhnd
=fopen(newname,io_write
);
new buf2
[1];
new i;
for (i
=flength(ohnd
);i
>0;i
--) { fputchar(nhnd,
fgetchar(ohnd, buf2
[0],false
),false
);
} fclose(ohnd
);
fclose(nhnd
);
return true;
}/**
* Copies a textfile (Source file won't be deleted!)
* @param oldname
* newname
*/stock fcopytextfile
(oldname
[],newname
[]) { new File:ohnd,
File:nhnd;
if (!fexist(oldname
)) return false;
ohnd
=fopen(oldname,io_read
);
nhnd
=fopen(newname,io_write
);
new tmpres
[MAX_STRING
];
while (fread(ohnd,tmpres
)) { StripNewLine
(tmpres
);
format(tmpres,
sizeof(tmpres
),
"%s\r\n",tmpres
);
fwrite(nhnd,tmpres
);
} fclose(ohnd
);
fclose(nhnd
);
return true;
}/**
* Renames a file (Source file will be deleted!)
* @param oldname
* newname
* @requires WINDOWS (because fcopy does)
*/stock frename
(oldname
[],newname
[]) { if (!fexist(oldname
)) return false;
fremove(newname
);
if (!fcopy
(oldname,newname
)) return false;
fremove(oldname
);
return true;
}/**
* Renames a file (Source file will be deleted!)
* @param oldname
* newname
*/stock frenametextfile
(oldname
[],newname
[]) { if (!fexist(oldname
)) return false;
fremove(newname
);
if (!fcopytextfile
(oldname,newname
)) return false;
fremove(oldname
);
return true;
}/**
* Strips Newline from the end of a string.
* Idea: ******, Bugfixing (when length=1) by DracoBlue
* @param string
*/stock StripNewLine
(string
[]){ new len
= strlen(string
);
if (string
[0]==0) return ;
if ((string
[len
- 1] == '\n') ||
(string
[len
- 1] == '\r')) { string
[len
- 1] = 0;
if (string
[0]==0) return ;
if ((string
[len
- 2] == '\n') ||
(string
[len
- 2] == '\r')) string
[len
- 2] = 0;
}}/**
* Copies items from one array/string into return.
* @param source
* index (where to start, 0 is first)
* numbytes (how much)
*/ret_memcpy
(source
[],index
=0,numbytes
) { new tmp
[MAX_STRING
];
new i
=0;
tmp
[0]=0;
if (index
>=strlen(source
)) return tmp;
if (numbytes
+index
>=strlen(source
)) numbytes
=strlen(source
)-index;
if (numbytes
<=0) return tmp;
for (i
=index;i
<numbytes
+index;i
++) { tmp
[i
-index
]=source
[i
];
if (source
[i
]==0) return tmp;
} tmp
[numbytes
]=0;
return tmp;
}/**
* Copies items from one array/string into another.
* @param dest
* source
* count
*/stock copy
(dest
[],source
[],count
) { dest
[0]=0;
if (count
<0) return false;
if (count
>strlen
(source
)) count
=strlen(source
);
new i
=0;
for (i
=0;i
<count;i
++) { dest
[i
]=source
[i
];
if (source
[i
]==0) return true;
} dest
[count
]=0;
return true;
}/**
* Deletes the first 'count' items of a array/string
* @param string[]
* count
*/stock delete
(string
[],count
) { new tmp
[MAX_STRING
];
tmp
[0]=0;
if (count
<=0) { format(tmp,
sizeof(tmp
),
"%s",string
);
return tmp;
} tmp
=ret_memcpy
(string,count,
strlen(string
));
return tmp;
}/**
* Sets a string's value to source.
* @param dest
* source
* count
*/stock set
(dest
[],source
[]) { new count
= strlen(source
);
new i
=0;
for (i
=0;i
<count;i
++) { dest
[i
]=source
[i
];
} dest
[count
]=0;
}/**
* Checks wether two strings are equal (case insensetive)
* @param str1
* str2
*/stock equal
(str1
[],str2
[],
bool:ignorecase
) { if (strlen(str1
)!=strlen(str2
)) return false;
if (strcmp(str1,str2,ignorecase
)==0) return true;
return false;
}/**
* Returns an element of a string splitted by ' ', default index is 0.
* @param string
* index
*/stock strtok
(const string
[],
&index,seperator
=' '){ new length
= strlen(string
);
new offset
= index;
new result
[MAX_STRING
];
while ((index
< length
) && (string
[index
] != seperator
) && ((index
- offset
) < (sizeof(result
) - 1))) { result
[index
- offset
] = string
[index
];
index
++;
} result
[index
- offset
] = EOS;
if ((index
< length
) && (string
[index
] == seperator
)) { index
++;
} return result;
}stock mod
(up,down
) { return up
-(floatround((up
/down
),floatround_floor
))*down;
}stock div
(up,down
) { return (floatround((up
/down
),floatround_floor
));
}/**
* Returns a hashed value in adler32 as int
* @param buf
*/stock num_hash
(buf
[]) { new length
=strlen(buf
);
new s1
= 1;
new s2
= 0;
new n;
for (n
=0; n
<length; n
++) { s1
= (s1
+ buf
[n
]) % 65521;
s2
= (s2
+ s1
) % 65521;
} return (s2
<< 16) + s1;
}/**
* Returns a hashed value in adler32 as string
* @param buf
*/stock hash
(str2
[]) { new tmpdasdsa
[MAX_STRING
];
tmpdasdsa
[0]=0;
valstr(tmpdasdsa,num_hash
(str2
));
return tmpdasdsa;
}/**
* Returns a string which has 'newstr' where 'trg' was before
* @param trg
* newstr
* src
*/stock strreplace
(trg
[],newstr
[],src
[]) { new f
=0;
new s1
[MAX_STRING
];
new tmp
[MAX_STRING
];
format(s1,
sizeof(s1
),
"%s",src
);
f
= strfind(s1,trg
);
tmp
[0]=0;
while (f
>=0) { strcat(tmp,ret_memcpy
(s1,
0, f
));
strcat(tmp,newstr
);
format(s1,
sizeof(s1
),
"%s",ret_memcpy
(s1, f
+strlen(trg
),
strlen(s1
)-f
));
f
= strfind(s1,trg
);
} strcat(tmp,s1
);
return tmp;
}/**
* Returns the string with lowercase
* @param txt
*/stock strlower
(txt
[]) { new tmp
[MAX_STRING
];
tmp
[0]=0;
if (txt
[0]==0) return tmp;
new i
=0;
for (i
=0;i
<strlen
(txt
);i
++) { tmp
[i
]=tolower(txt
[i
]);
} tmp
[strlen(txt
)]=0;
return tmp;
}/**
* Returns the string with uppercase
* @param txt
*/stock strupper
(txt
[]) { new tmp
[MAX_STRING
];
tmp
[0]=0;
if (txt
[0]==0) return tmp;
new i
=0;
for (i
=0;i
<strlen
(txt
);i
++) { tmp
[i
]=toupper(txt
[i
]);
} tmp
[strlen(txt
)]=0;
return tmp;
}