SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 01/03/2012, 02:30 PM   #1
Ballu Miaa
High-roller
 
Ballu Miaa's Avatar
 
Join Date: Apr 2010
Location: New Delhi,India
Posts: 1,911
Reputation: 313
Default bLibrary(22 functions and 1 custom callback)

- 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 Code:
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 Code:
public OnPlayerEnterWater(playerid)//Is called when a player enters water.
- How to Use Functions -
SetPlayerCash
pawn Code:
if(!strcmp(cmdtext, "/cash", true))
    {
        SetPlayerCash(playerid, 10000);
        return 1;
       
    }
RemovePlayerCash
pawn Code:
if(!strcmp(cmdtext, "/nocash", true))
    {
        RemovePlayerCash(playerid, 10000);
        return 1;
       
    }
GivePlayerScore
pawn Code:
if(!strcmp(cmdtext, "/score", true))
    {
        GivePlayerScore(playerid, 100);
        return 1;
       
    }
RemovePlayerScore
pawn Code:
if(!strcmp(cmdtext, "/noscore", true))
    {
        RemovePlayerScore(playerid, 50);
        return 1;
       
    }
GetVehicleIDByName
pawn Code:
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 Code:
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 Code:
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 Code:
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 Code:
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 Code:
if(!strcmp(cmdtext, "/pos", true))
    {
        SetPlayerPosEx(playerid, 0.0, 0.0, 0.0, 0, 0, 1);
        return 1;
       
    }
KickAll
pawn Code:
if(!strcmp(cmdtext, "/kickall", true))
    {
        KickAll();
        return 1;
       
    }
BanAll
pawn Code:
if(!strcmp(cmdtext, "/banall", true))
    {
        BanAll();
        return 1;
       
    }
FreezeAll
pawn Code:
if(!strcmp(cmdtext, "/freezeall", true))
    {
        FreezeAll();
        return 1;
       
    }
UnfreezeAll
pawn Code:
if(!strcmp(cmdtext, "/unfreezeall", true))
    {
        UnfreezeAll();
        return 1;
       
    }
Freeze
pawn Code:
if(!strcmp(cmdtext, "/freeze", true))
    {
        Freeze(playerid);
        return 1;
       
    }
Unfreeze
pawn Code:
if(!strcmp(cmdtext, "/unfreeze", true))
    {
        Unfreeze(playerid);
        return 1;
       
    }
GetPlayerIPEx
pawn Code:
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 Code:
if(!strcmp(cmdtext, "/boom", true))
    {
        Explode(playerid);
        return 1;
       
    }
ExplodeAll
pawn Code:
if(!strcmp(cmdtext, "/bigbang", true))
    {
        ExplodeAll();
        return 1;
       
    }
Kill
pawn Code:
if(!strcmp(cmdtext, "/kill", true))
    {
        Kill();
        return 1;
       
    }
KillAll
pawn Code:
if(!strcmp(cmdtext, "/killall", true))
    {
        KillAll();
        return 1;
       
    }
ShowMessage
pawn Code:
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 Code:
public OnPlayerEnterWater(playerid)
{
    //Your Code Here
    return 1;
}
- Thanks -
Hope you liked my script.
regards,

Ballu Miaa
__________________


I will take half payment as an advance to script for you.
Click here to request my Scripting Service.


Last edited by Ballu Miaa; 17/03/2013 at 09:26 AM.
Ballu Miaa is offline   Reply With Quote
Old 01/03/2012, 03:11 PM   #2
Littlehelper
Gangsta
 
Littlehelper's Avatar
 
Join Date: Nov 2011
Location: 420
Posts: 967
Reputation: 178
Default Re: bLibrary(22 functions and 1 custom callback)

Nice release.
Good Job!
__________________
Quote:
<Norsehawk> If pigs flew, we'd need stronger umbrellas
<Norsehawk> and if my cat shat gold, I would be rich...
My Steam Profile (from SteamDB)
  • Worth: $1511.27
  • Games owned: 146
  • Games not played: 77
  • Percentage: 53%
  • Hours spent: 307.0h
Littlehelper is offline   Reply With Quote
Old 01/03/2012, 03:18 PM   #3
Ballu Miaa
High-roller
 
Ballu Miaa's Avatar
 
Join Date: Apr 2010
Location: New Delhi,India
Posts: 1,911
Reputation: 313
Default Re: bLibrary(22 functions and 1 custom callback)

Thanks mate.
i am glad you liked it!!
__________________


I will take half payment as an advance to script for you.
Click here to request my Scripting Service.

Ballu Miaa is offline   Reply With Quote
Old 01/03/2012, 03:38 PM   #4
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,364
Reputation: 131
Default Re: bLibrary(22 functions and 1 custom callback)

pawn Code:
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.
wups is offline   Reply With Quote
Old 01/03/2012, 03:43 PM   #5
Psymetrix
Huge Clucker
 
Join Date: Oct 2011
Posts: 302
Reputation: 88
Default Re: bLibrary(22 functions and 1 custom callback)

Don't create variables inside a loop.

Bad:
pawn Code:
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 Code:
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);
        }
}
Psymetrix is offline   Reply With Quote
Old 01/03/2012, 04:05 PM   #6
Ballu Miaa
High-roller
 
Ballu Miaa's Avatar
 
Join Date: Apr 2010
Location: New Delhi,India
Posts: 1,911
Reputation: 313
Default Re: bLibrary(22 functions and 1 custom callback)

Quote:
Originally Posted by wups View Post
pawn Code:
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 View Post
Don't create variables inside a loop.

Bad:
pawn Code:
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 Code:
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!
__________________


I will take half payment as an advance to script for you.
Click here to request my Scripting Service.

Ballu Miaa is offline   Reply With Quote
Old 01/03/2012, 04:09 PM   #7
Aldo.
Big Clucker
 
Aldo.'s Avatar
 
Join Date: Jan 2011
Posts: 187
Reputation: 47
Default Re: bLibrary(22 functions and 1 custom callback)

I'm pretty sure after you found a match you should break the loop
__________________




Aldo. is offline   Reply With Quote
Old 01/03/2012, 04:19 PM   #8
Ballu Miaa
High-roller
 
Ballu Miaa's Avatar
 
Join Date: Apr 2010
Location: New Delhi,India
Posts: 1,911
Reputation: 313
Default Re: bLibrary(22 functions and 1 custom callback)

Quote:
Originally Posted by Aldo. View Post
I'm pretty sure after you found a match you should break the loop
Which loop you're talking about ?
__________________


I will take half payment as an advance to script for you.
Click here to request my Scripting Service.

Ballu Miaa is offline   Reply With Quote
Old 01/03/2012, 04:30 PM   #9
Psymetrix
Huge Clucker
 
Join Date: Oct 2011
Posts: 302
Reputation: 88
Default Re: bLibrary(22 functions and 1 custom callback)

Quote:
Originally Posted by Aldo. View Post
I'm pretty sure after you found a match you should break the loop
The return inside the loop breaks it.
Psymetrix is offline   Reply With Quote
Old 01/03/2012, 04:32 PM   #10
iTorran
Gangsta
 
Join Date: Aug 2010
Posts: 554
Reputation: 88
Default Re: bLibrary(22 functions and 1 custom callback)

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);
                }
        }
}
iTorran is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
callback xir Help Archive 14 18/03/2011 03:48 PM
Custom Functions benyaminx Help Archive 5 13/07/2010 12:12 PM
[Include] [INC] LSF - Lorenc's Simple Functions (w/ gang/clan functions) Lorenc_ Includes 11 03/05/2010 09:47 PM
Custom callback error _Vortex Help Archive 6 13/08/2009 01:44 AM


All times are GMT. The time now is 10:17 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.