[Include] clFunction - CreativityLacker's custom functions
#1

CreativityLacker's custom miscellaneous functions


Just a lot of useful functions which might come in handy. Don't bitch about it, It's meant to be a personal tool but I'm releasing it.
Quote:
native GetPlayersName(playerid)
native SetPlayerPositionEx(playerid, Float, Float:y, Float:z, Float:angle, vworld, interior)
native TeleportPlayerToPlayer(playerid, targetid)
native TeleportCarToPlayer(vehicleid, playerid)
native TeleportPlayerToCar(playerid, vehicleid)
native GetPlayerIPAddress(playerid)
native HealPlayer(playerid)
native KillPlayer(playerid)
native CrashPlayer(playerid)
native GivePlayerHealth(playerid, Float:health)
native TakePlayerHealth(playerid, Float:health)
native GivePlayerArmour(playerid, Float:armour)
native TakePlayerArmour(playerid, Float:armour)
native GivePlayerScore(playerid, score)
native TakePlayerScore(playerid, score)
native GiveScoreFromPlayerToPlayer(playerid, targetid, score)
native GiveCashFromPlayerToPlayer(playerid, targetid, amount)
native BankruptPlayer(playerid)
native SetPlayerCash(playerid)
native SlapPlayer(playerid)
native IsPlayerSwimming(playerid)
native IsPlayerFalling(playerid)
native IsPlayerInModdingShop(playerid)
native GetVehicleType(modelid)
stock GetPlayerVehicleSpeed(playerid)
native ExplodePlayer(playerid)
native IsPlayerAiming(playerid)
native GetWeaponNameByID(weaponid)
native GetWeaponIDByName(weaponname[])
native GetWeaponSlotByID(weaponid)
native GetPlayerArmedWeaponAmmo(playerid)
native GetVehicleNameByModel(model)
native GetWeatherName(weatherid)
native LoadObjectsFromFile(const filename[])
native LoadVehiclesFromFile(const filename[])
native CreateLogEntry(log[], text[])
native HealAll()
native ArmourAll()
native FreezeAll()
native DisarmAll()
native GiveWeaponToAll(weaponid, ammo)
native GiveCashToAll(cash)
native GiveScoreToAll(score)
native UnfreezeAll()
native GetOnlinePlayersCount()
native GetValidVehiclesCount()









Explanations


Well, most of the functions are self-explanatory but some functions require explanations so -


LoadObjectsFromFile(const filename[])

This is a simple function to load CreateObject lines from a file.
const filename[] should be like "Objects.txt" or "Maps/Objects.txt" since it's the FOLDER PATH INSIDE THE SCRIPTFILES FOLDER.

NOTE: DO NOT use this function twice with a timer, else it'll result in the server creating double of the same objects. I suggest if you're gonna use this for a stunt, then you load all the objects on game mode in it ORRRRRRRR if you're going for a map-chaning-tdm-thing, Then I suggest you make custom functions - StartMap(mapid) and EndMap() and load and destroy objects whenever they're called to avoid extra-useless objects

LoadVehiclesFromFile
Same as LoadObjectsFromFile, except it loads vehicles

GetVehicleType
pawn Код:
#define TYPE_INVALID    -1
#define TYPE_AIRPLANE   0
#define TYPE_HELICOPTER 1
#define TYPE_BIKE   2
#define TYPE_CONVERTIBLE    3
#define TYPE_INDUSTRIAL     4
#define TYPE_LOWRIDER       5
#define TYPE_OFFROAD        6
#define TYPE_PUBLIC 7
#define TYPE_SALOON         8
#define TYPE_SPORT  9
#define TYPE_STATION    10
#define TYPE_BOAT   11
#define TYPE_TRAILER    12
#define TYPE_UNIQUE 13
#define TYPE_RC 14




Changelogs


10/14/2012 - Added pastebin link and explanation on request and advise
10/16/2012 - Added many new functions, V2 released
09/11/2012 - Added many new functions, V2.25 released
09/11/2012 - Fixed some minor bugs, Functions will work correctly now.
14/11/2012 - Fixed some major bugs, Added new functions, Fixed previous functions too.
Reply
#2

Why are they marked as native types?
Reply
#3

Just throwing in my five cents here:
  • Just about all of these are already released
  • There should be a Pastebin link
  • There should be an explanation for LoadObjectsFromFile and possibly an implementation of SaveObjectsToFile
It's a good thing that you made these by yourself and didn't copy others. Kudos to you for that.
Reply
#4

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Just throwing in my five cents here:
  • Just about all of these are already released
  • There should be a Pastebin link
  • There should be an explanation for LoadObjectsFromFile and possibly an implementation of SaveObjectsToFile
It's a good thing that you made these by yourself and didn't copy others. Kudos to you for that.
1. I didn't know that, I'm sorry I just joined recently...
2. Adding ASAP.
3. Adding after adding pastebin link.

Thanks for appreciating.

EDIT - added explanation and pastebin link but I need help.
I'm making SaveObjectsToFile but Idk how to get the Objects model e.e
Reply
#5

Added a lot of new functions. Version 2 released. Please suggest if you'd like to have another function in this.
Reply
#6

Nice work! Most of the functions in it are pretty useful.
Reply
#7

stock GetValidVehiclesCount()
{
new count;
for(new x = 0; x < MAX_VEHICLES; x++)
{
if(x != INVALID_VEHICLE_ID)
{
count++;
}
}
return count;
}

Are you sure that works?
How can a static, defined number equal a dynamic number in a for loop?
Reply
#8

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
stock GetValidVehiclesCount()
{
new count;
for(new x = 0; x < MAX_VEHICLES; x++)
{
if(x != INVALID_VEHICLE_ID)
{
count++;
}
}
return count;
}

Are you sure that works?
How can a static, defined number equal a dynamic number in a for loop?
Well, I didn't try it, But seeing it from the code, It looked fine when I was done with it though I did doubt that the check for checking if the vehicle is valid might be wrong. I'll try it asap and see if it has any bugs, Thanks for pointing it out though.

EDIT - Didn't work, I tried it with grand larc, The original count was 1750 something while the script counted 2000 vehicles, I'll work on it.
Reply
#9

PHP код:
stock GetValidVehiclesCount()
{
        new 
count;
        for(new 
1<= MAX_VEHICLESx++)
        {
            switch(
GetVehicleModel(x))
            {
                case 
400..611count++;
                default: continue;
            }
        }
        return 
count;

Also, there is no vehicle with id 0. Only from 1 to 2000.
Reply
#10

Quote:
Originally Posted by SDraw
Посмотреть сообщение
PHP код:
stock GetValidVehiclesCount()
{
        new 
count;
        for(new 
1<= MAX_VEHICLESx++)
        {
            switch(
GetVehicleModel(x))
            {
                case 
400..611count++;
                default: continue;
            }
        }
        return 
count;

Also, there is no vehicle with id 0. Only from 1 to 2000.
Result with that code is 2000 vehicles while grand larc says only 1781 vehicles were loaded from the files? e.e
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)