[Include] bLibrary(22 functions and 1 custom callback)
#1

- Introduction -
I decided to release this small library i made within 15-20 minutes.I hope you like this.It has 22 custom functions as well as 1 custom callback.I know its pretty simple to make for intermediate and advanced scripter's. But beginner's still have lot of problem's with creating all these function's. So Just made a library for it. So that they can use this library for their game mode.

- Natives -
pawn Код:
native SetPlayerCash(playerid, cash);
//Description - Sets the player's cash
native RemovePlayerCash(playerid, cash);
//Description - Removes the player's cash.Don't type -cash i.e RemovePlayerCash(playerid, -1000) just write RemovePlayerCash(playerid, 1000);
native GivePlayerScore(playerid, score);
//Description - Gives Player Score
native RemovePlayerScore(playerid, score);
//Description - Removes the player's score.Don't type -score i.e RemovePlayerScore(playerid, -1000) just write RemovePlayerScore(playerid, 1000);
native GetVehicleIDByName(name[]);
//Description - Gets the ID of the vehicle by it's name
native GetWeaponIDByName(name[]);
//Description - Gets the ID of the weapon by it's name
native GetVehicleNameByModel(model);
//Description - Gets the name of the vehicle by it's ID
native GetWeaponNameByID(id);
//Description - Gets the name of the weapon by it's ID
native GetPlayerNameEx(playerid);
//Description - A much better way to Get the player's name
native SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Angle,interior,VirtualWorld);
//Description - Sets the players position.Interior and Virtual World are optional parameters.
native KickAll();
//Description - Self Explanatory
native BanAll();
//Description - Self Explanatory
native FreezeAll();
//Description - Self Explanatory
native UnfreezeAll();
//Description - Self Explanatory
native Freeze(playerid);
//Description - Self Explanatory
native Unfreeze(playerid);
//Description - Self Explanatory
native GetPlayerIPEx(playerid);
//Description - Gets a player's IP
native Explode(playerid);
//Description - Self Explanatory
native ExplodeAll();
//Description - Self Explanatory
native Kill(playerid);
//Description -  Self Explanatory
native KillAll();
//Description - Self Explanatory
native ShowMessage(playerid, caption[], info[]);
//Description - Shows a Message Box
- Callback -
pawn Код:
public OnPlayerEnterWater(playerid)//Is called when a player enters water.
- How to Use Functions -
SetPlayerCash
pawn Код:
if(!strcmp(cmdtext, "/cash", true))
    {
        SetPlayerCash(playerid, 10000);
        return 1;
       
    }
RemovePlayerCash
pawn Код:
if(!strcmp(cmdtext, "/nocash", true))
    {
        RemovePlayerCash(playerid, 10000);
        return 1;
       
    }
GivePlayerScore
pawn Код:
if(!strcmp(cmdtext, "/score", true))
    {
        GivePlayerScore(playerid, 100);
        return 1;
       
    }
RemovePlayerScore
pawn Код:
if(!strcmp(cmdtext, "/noscore", true))
    {
        RemovePlayerScore(playerid, 50);
        return 1;
       
    }
GetVehicleIDByName
pawn Код:
if(!strcmp(cmdtext, "/car", true))    
   {
    new vehicle = GetVehicleIdByName(params); //converts the vehiclename to modelID
    if(vehicle == -1) return SendClientMessage(playerid,-1,"Invalid vehicle name!");
    new Float:pos[3];GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    CreateVehicle(vehicle,pos[0],pos[1],pos[2]);
    return 1;
}
GetWeaponIDByName
pawn Код:
if(!strcmp(cmdtext, "/weapon", true))
    {
            new weapon = GetWeaponIdByName(params); //converts the weaponname to weaponmodel
            if(weapon == -1) return SendClientMessage(playerid,-1,"Invalid weapon name!");
            GivePlayerWeapon(playerid,weapon,100);
        return 1;
       
    }
GetVehicleNameByModel
pawn Код:
if(!strcmp(cmdtext, "/vehiclename", true))
    {
        new vehicle = GetVehicleNameByModel(432);
        new string[125];
        format(string, sizeof(string), "You are currently sitting in a %s", vehicle);
        SendClientMessage(playerid, -1, string);
        return 1;
       
    }
GetWeaponNameByID
pawn Код:
if(!strcmp(cmdtext, "/weaponname", true))
    {
        new weapon = GetWeaponNameByID(2);
        new string[125];
        format(string, sizeof(string), "You currently have a %s in hand", weapon);
        SendClientMessage(playerid, -1, string);
        return 1;
       
    }
GetPlayerNameEx
pawn Код:
if(!strcmp(cmdtext, "/name", true))
    {
        new string[125];
        format(string, sizeof(string), "Your name is %s", GetPlayerNameEx(playerid));
        SendClientMessage(playerid, -1, string);
        return 1;
       
    }
SetPlayerPosEx
pawn Код:
if(!strcmp(cmdtext, "/pos", true))
    {
        SetPlayerPosEx(playerid, 0.0, 0.0, 0.0, 0, 0, 1);
        return 1;
       
    }
KickAll
pawn Код:
if(!strcmp(cmdtext, "/kickall", true))
    {
        KickAll();
        return 1;
       
    }
BanAll
pawn Код:
if(!strcmp(cmdtext, "/banall", true))
    {
        BanAll();
        return 1;
       
    }
FreezeAll
pawn Код:
if(!strcmp(cmdtext, "/freezeall", true))
    {
        FreezeAll();
        return 1;
       
    }
UnfreezeAll
pawn Код:
if(!strcmp(cmdtext, "/unfreezeall", true))
    {
        UnfreezeAll();
        return 1;
       
    }
Freeze
pawn Код:
if(!strcmp(cmdtext, "/freeze", true))
    {
        Freeze(playerid);
        return 1;
       
    }
Unfreeze
pawn Код:
if(!strcmp(cmdtext, "/unfreeze", true))
    {
        Unfreeze(playerid);
        return 1;
       
    }
GetPlayerIPEx
pawn Код:
if(!strcmp(cmdtext, "/myip", true))
    {
        new ip = GetPlayerIPEx(playerid);
        new string[125];
        format(string, sizeof(string), "Your ip is %d", ip);
        SendClientMessage(playeridm -1, string);
        return 1;
       
    }
Explode
pawn Код:
if(!strcmp(cmdtext, "/boom", true))
    {
        Explode(playerid);
        return 1;
       
    }
ExplodeAll
pawn Код:
if(!strcmp(cmdtext, "/bigbang", true))
    {
        ExplodeAll();
        return 1;
       
    }
Kill
pawn Код:
if(!strcmp(cmdtext, "/kill", true))
    {
        Kill();
        return 1;
       
    }
KillAll
pawn Код:
if(!strcmp(cmdtext, "/killall", true))
    {
        KillAll();
        return 1;
       
    }
ShowMessage
pawn Код:
if(!strcmp(cmdtext, "/hi", true))
    {
        ShowMessage(playerid, "Hello", "Hello");
        return 1;
       
    }
- Download -
- PasteBin - v1.1 (Recommended) (New Release)
- How to Use Callback -
To use the callback just add this anywhere is your script
pawn Код:
public OnPlayerEnterWater(playerid)
{
    //Your Code Here
    return 1;
}
- Thanks -
Hope you liked my script.
regards,

Ballu Miaa
Reply
#2

Nice release.
Good Job!
Reply
#3

Thanks mate.
i am glad you liked it!!
Reply
#4

pawn Код:
if(!strcmp(cmdtext, "/killall", true))
    {
        KillAll;
        return 1;
       
    }
if(!strcmp(cmdtext, "/vehiclename", true))
    {
        new vehicle = GetVehicleNameByModel(432);
        new string[125];
        format(string, sizeof(string), "You are currently sitting in a %s", vehicle);
        SendClientMessage(playerid, -1, string);
        return 1;
       
    }
Bad examples..
Function can't be writen like that(KickAll. You must use brackets ().
As for the vehicle name, you're storring it's name in to an integer.
Reply
#5

Don't create variables inside a loop.

Bad:
pawn Код:
stock ExplodeAll()
{
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(i, X, Y, Z);
                CreateExplosion(X, Y, Z, 7, 100.0);
        }
}
Good:
pawn Код:
stock ExplodeAll()
{
        new Float:X, Float:Y, Float:Z;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                GetPlayerPos(i, X, Y, Z);
                CreateExplosion(X, Y, Z, 7, 100.0);
        }
}
Reply
#6

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext, "/killall", true))
    {
        KillAll;
        return 1;
       
    }
if(!strcmp(cmdtext, "/vehiclename", true))
    {
        new vehicle = GetVehicleNameByModel(432);
        new string[125];
        format(string, sizeof(string), "You are currently sitting in a %s", vehicle);
        SendClientMessage(playerid, -1, string);
        return 1;
       
    }
Bad examples..
Function can't be writen like that(KickAll. You must use brackets ().
As for the vehicle name, you're storring it's name in to an integer.
Sorry for that mate. I know but idk how i just forgot to add parenthesis in those function's.
Thanks for notifying.

Quote:
Originally Posted by Psymetrix
Посмотреть сообщение
Don't create variables inside a loop.

Bad:
pawn Код:
stock ExplodeAll()
{
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(i, X, Y, Z);
                CreateExplosion(X, Y, Z, 7, 100.0);
        }
}
Good:
pawn Код:
stock ExplodeAll()
{
        new Float:X, Float:Y, Float:Z;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                GetPlayerPos(i, X, Y, Z);
                CreateExplosion(X, Y, Z, 7, 100.0);
        }
}
Oh yeah. Thanks for the knowledge , will keep in mind next time! Updating the include!
Reply
#7

I'm pretty sure after you found a match you should break the loop
Reply
#8

Quote:
Originally Posted by Aldo.
Посмотреть сообщение
I'm pretty sure after you found a match you should break the loop
Which loop you're talking about ?
Reply
#9

Quote:
Originally Posted by Aldo.
Посмотреть сообщение
I'm pretty sure after you found a match you should break the loop
The return inside the loop breaks it.
Reply
#10

pawn Код:
stock ExplodeAll()
{
        new Float:X, Float:Y, Float:Z;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(IsPlayerConnected(i))
                {
                        GetPlayerPos(i, X, Y, Z);
                        CreateExplosion(X, Y, Z, 7, 100.0);
                }
        }
}
Reply
#11

Quote:
Originally Posted by Psymetrix
View Post
The return inside the loop breaks it.
Quote:
Originally Posted by iTorran
View Post
pawn Code:
stock ExplodeAll()
{
        new Float:X, Float:Y, Float:Z;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(IsPlayerConnected(i))
                {
                        GetPlayerPos(i, X, Y, Z);
                        CreateExplosion(X, Y, Z, 7, 100.0);
                }
        }
}
This loop? Its not returning any value? What's the problem?
Reply
#12

Quote:
Originally Posted by iTorran
View Post
[pawn]stock ExplodeAll...
Why post a function without an explanation?

Quote:
Originally Posted by Ballu Miaa
View Post
This loop? Its not returning any value? What's the problem?
Theres no problem with it. I was referring to the other loops in the include.
Reply
#13

Quote:
Originally Posted by Psymetrix
View Post
Why post a function without an explanation?


Theres no problem with it. I was referring to the other loops in the include.
Allright will add more explanation later. Thanks for the tip mate.
Reply
#14

nice release,thanks
Reply
#15

Quote:
Originally Posted by xkirill
View Post
nice release,thanks
I am glad you liked it mate!!
Reply
#16

Sorry thought i added something to the code i posted..
I added a check to see if the player you're exploding is connected
Reply
#17

Quote:
Originally Posted by iTorran
View Post
Sorry thought i added something to the code i posted..
I added a check to see if the player you're exploding is connected
Its okay. Not a big Issue!
Reply
#18

Nice include mate..
Reply
#19

Quote:
Originally Posted by [HK]Ryder[AN]
View Post
Nice include mate..
Thanks bruh!
Reply
#20

OMG this one is epic release!!
i <3 the onplayerenter water thingy , really new
Keep it up mate!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)