SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/01/2018, 11:57 PM   #1251
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 558
Reputation: 73
Default Re: Useful Snippets

Quote:
Originally Posted by RogueDrifter View Post
This is how i looped through cars for empty drivers, it took me some good thinking to come up with this i dunno how you'd do this in any other way since the concept isn't based as a samp feature it would be easier if u knew your vehicle id but i wanted to loop through ALL cars that had no driver so anyway here's my code if anyone knows a more optimized way to do this i'd love to hear it.
PHP Code:
forward LoopNDCars();
public 
LoopNDCars()
{
    new 
AllVehicles[MAX_VEHICLES];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
GetPlayerState(i)== PLAYER_STATE_DRIVER && AllVehicles[GetPlayerVehicleID(i)] != )
        {
            
AllVehicles[GetPlayerVehicleID(i)]= i;
            }
        }
    for(new 
x=0x<MAX_VEHICLESx++)
    {
        if(
AllVehicles[x] != -1)
        {
            if(
GetPlayerState(AllVehicles[x]) != PLAYER_STATE_DRIVERAllVehicles[x] = -1;
            }
        if(
AllVehicles[x] == -1)
        {
            
//This will get called for all cars that have no driver.
            
}
        }
    return 
1;

This could really be concise immensely, but a good effort nonetheless.
ISmokezU is offline   Reply With Quote
Old 17/01/2018, 12:02 AM   #1252
ThePhenix
Gangsta
 
ThePhenix's Avatar
 
Join Date: May 2012
Posts: 825
Reputation: 153
Default Re: Useful Snippets

The function you just posted could be tweaked a little bit as it is meaningless to loop through vehicles that have not been created yet.

Hence, you should use:

http://wiki.sa-mp.com/wiki/IsValidVehicle

PHP Code:
stock LoopNDCars()
{
    new 
AllVehicles[MAX_VEHICLES];
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
GetPlayerState(i)== PLAYER_STATE_DRIVER && AllVehicles[GetPlayerVehicleID(i)] != )
        {
            
AllVehicles[GetPlayerVehicleID(i)]= i;
        }
    }
    for(new 
x=0x<MAX_VEHICLESx++)
    {
        if(!
IsValidVehicle(x)) continue; //this line will increase performance
        
if(AllVehicles[x] != -1)
        {
            if(
GetPlayerState(AllVehicles[x]) != PLAYER_STATE_DRIVERAllVehicles[x] = -1;
        }
        if(
AllVehicles[x] == -1)
        {
            
//This will get called for all cars that have no driver.
           
          
}
      }
    return 
1;

Additionally, here is an implementation I haven't tested but I came up with:

EDIT: forgot to use IsPlayerConnected, could use foreach for more performance:
PHP Code:
//Loops through unoccupied vehicles:
    
    
for(new 0MAX_VEHICLESi++)
    {
        if(!
IsValidVehicle(i)) continue;

        new 
bool:is_occupied false;
        for(new 
0MAX_PLAYERSp++)
        {
            if(!
IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better
            
if(IsPlayerInVehicle(pi))
            {
                
is_occupied true;
                break; 
//avoid any more useless loops, we know the vehicle is occupied
            
}
        }
        if(!
is_occupied//without any driver
        
{
            
//do something with the unoccupied vehicle with ID: i
        
}
    } 
ThePhenix is offline   Reply With Quote
Old 17/01/2018, 12:16 AM   #1253
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,472
Reputation: 291
Default Re: Useful Snippets

Aha thanks! i edited my post with that valid thing and i'll check your implementation once i get time but just a comment shouldn't this:
PHP Code:
new bool:is_occupied false
        for(new 
0MAX_PLAYERSp++) 
        { 
            if(!
IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better 
            
if(IsPlayerInVehicle(pi)) 
            { 
                
is_occupied true
                break; 
//avoid any more useless loops, we know the vehicle is occupied 
            

        } 
        if(!
is_occupied//without any driver 
be like this?
PHP Code:
new bool:is_occupied[MAX_VEHICLES] = false;
        for(new 
0MAX_PLAYERSp++)
        {
            if(!
IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better
            
if(IsPlayerInVehicle(pi))
            {
                
is_occupied[i] = true;
                break; 
//avoid any more useless loops, we know the vehicle is occupied
            
}
        }
        if(!
is_occupied[i]) //without any driver 
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link




RogueDrifter is offline   Reply With Quote
Old 17/01/2018, 12:24 AM   #1254
ThePhenix
Gangsta
 
ThePhenix's Avatar
 
Join Date: May 2012
Posts: 825
Reputation: 153
Default Re: Useful Snippets

Quote:
Originally Posted by RogueDrifter View Post
Aha thanks! i edited my post with that valid thing and i'll check your implementation once i get time but just a comment shouldn't this:
PHP Code:
new bool:is_occupied false
        for(new 
0MAX_PLAYERSp++) 
        { 
            if(!
IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better 
            
if(IsPlayerInVehicle(pi)) 
            { 
                
is_occupied true
                break; 
//avoid any more useless loops, we know the vehicle is occupied 
            

        } 
        if(!
is_occupied//without any driver 
be like this?
PHP Code:
new bool:is_occupied[MAX_VEHICLES] = false;
        for(new 
0MAX_PLAYERSp++)
        {
            if(!
IsPlayerConnected(p)) continue; //Forgot this, foreach could be even better
            
if(IsPlayerInVehicle(pi))
            {
                
is_occupied[i] = true;
                break; 
//avoid any more useless loops, we know the vehicle is occupied
            
}
        }
        if(!
is_occupied[i]) //without any driver 
Well, it would be really pointless to use an array for this case (loop through all the unoccupied vehicles), as the variable is_occupied only serves the purpose of telling you whether the vehicle with ID: i is occupied or not and if so it's value changes to true. This line:

PHP Code:
if(!is_occupied
Simply checks whether is_occupied was not changed for vehicle ID: i

If you wanted to make an array of the unoccupied vehicles (can't find a use for that) then what you propose might be possible.
ThePhenix is offline   Reply With Quote
Old 17/01/2018, 12:27 AM   #1255
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,472
Reputation: 291
Default Re: Useful Snippets

Quote:
Originally Posted by ThePhenix View Post
Well, it would be really pointless to use an array for this case (loop through all the unoccupied vehicles), as the variable is_occupied only serves the purpose of telling you whether the vehicle with ID: i is occupied or not and if so it's value changes to true. This line:

PHP Code:
if(!is_occupied
Simply checks whether is_occupied was not changed for vehicle ID: i

If you wanted to make an array of the unoccupied vehicles (can't find a use for that) then what you propose might be possible.
Ohh now i see the use for it thanks for the clarification :)
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link




RogueDrifter is offline   Reply With Quote
Old 29/01/2018, 12:08 AM   #1256
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,472
Reputation: 291
Default Re: Useful Snippets

This function will return the slot of the weapon id you insert into it: GetWeaponSlot(weaponid)
PHP Code:
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: return 4;
        case 
32:     return 4;
        case 
30..31: return 5;
        case 
33..34: return 6;
        case 
35..38: return 7;
        case 
16..18: return 8;
        case 
39:     return 8;
        case 
41..43: return 9;
        case 
10..15: return 10;
        case 
44..46: return 11;
        case 
40:     return 12;
    }
    return -
1;

Can be helpful if u use GetPlayerWeaponData so you won't need to look online for the weapon's slot.
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link





Last edited by RogueDrifter; 28/02/2018 at 01:09 PM.
RogueDrifter is offline   Reply With Quote
Old 10/02/2018, 09:00 AM   #1257
RxErT
Huge Clucker
 
RxErT's Avatar
 
Join Date: May 2016
Location: SA:MP Lemon
Posts: 228
Reputation: 12
Default Simple Whisper and Car Whisper commands controllable

*Features:
This system contain, 4 commands, are the following:
-/w (/whisper).
-/cw (whispering inside a car).
-/wspy (spying whisper messages).
-/cwspy (spying car whisper)


*Includes used:
-a_samp...
-Zeex command processor.
-sscanf2


Source:

Includes:

PHP Code:
//===Includes===//
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//-------------// 
Variables:
PHP Code:
//===Variables===//
new wspy[MAX_PLAYERS];
new 
cwspy[MAX_PLAYERS];
new 
pmspy[MAX_PLAYERS];
new 
IsSpawned[MAX_PLAYERS];
//=================// 
some optimization under public OnPlayerConnect(playerid) callback:

PHP Code:
public OnPlayerConnect(playerid)
{
   
IsSpawned[playerid] = 0;
   
wspy[playerid] = 0;
   
cwspy[playerid] = 0;
   
pmspy[playerid] = 0;
   return 
1;

Also under public OnPlayerSpawn(playerid):

PHP Code:
public OnPlayerSpawn(playerid)
{
   
IsSpawned[playerid] = 1;
   return 
1;

/*Car Whisper Code:*/
PHP Code:
CMD:cw(playeridparams[])
{
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        new 
string[250], textes[120], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridname,sizeof(name));

        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/cw <message>");
        }
        else
        {
            if(
IsPlayerInAnyVehicle(playerid))
            {
                new 
vehicleID GetPlayerVehicleID(playerid);

                new 
string2[250];
                
format(string2sizeof(string2), "{adf407}[Car Whisper] {FFFFFF}%s(%i): {adf407}%s",nameplayeridstring);

                for(new 
0<= MAX_PLAYERSi++)
                {
                    if(
IsPlayerInVehicle(ivehicleID))
                    {
                        
SendClientMessage(i, -1string2);
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid,0xf8f8f8fff"ERROR: {F00f00}You are not in a vehicle.");
            }
            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                        if (
IsPlayerAdmin(i))
                        {
                            if (
cwspy[i])
                            {
                                new 
cwtext[200];
                                
format(cwtextsizeof(cwtext), "{f00f00}[Car Whisper SPY]>> %s: %s",namestringtextes);
                                
SendClientMessage(i, -1cwtext);
                            }
                          }
                      }
                }
            }
        }
        return 
1;

/*Note: you can replaceIsPlayerAdmin(playerid) with your own administrator's system variable.*/

/* Car Whisper Spying */

PHP Code:
CMD:cwspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
cwspy[playerid])
            {
                
cwspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are not spying on car whisper.");
            }
            else
            {
                
cwspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {adf407}You are now spying on car whisper.");
            }
        }
    }
    return 
1;

/* Whisper */

PHP Code:
CMD:w(playeridparams[])
{
        new 
string[250];
        new 
nameplaya[MAX_PLAYER_NAME];
        new 
textes2[120];
        
GetPlayerName(playeridnameplaya,sizeof(nameplaya));
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/(w)hisper <message>");
        }
        else
        {
            new 
Float:x,Float:y,Float:z;
            
GetPlayerPos(playerid,x,y,z);

            new 
string2[250];
            
format(string2sizeof(string2), "{f47e07}[WHISPER] {FFFFFF}%s(%i): {f47e07}%s",nameplayaplayeridstring);

            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerInRangeOfPoint(i15.0xyz))
                {
                    
SendClientMessage(i, -1string2);
                    
PlayerPlaySound(i1085,0.0,0.0,0.0);
                }
                 if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerAdmin(i))
                    {
                         if (
wspy[i])
                        {
                        new 
wtext[200];
                        
format(wtextsizeof(wtext), "{f904e9}[WHISPER SPY]> {FFFFFF}%s: %s",nameplayastringtextes2);
                        
SendClientMessage(i, -1wtext);
                        }
                    }
                }
            }
        }
        return 
1;

/* Whisper spy */

PHP Code:
COMMAND:wspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
wspy[playerid])
            {
                
wspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are no longer spying on WHISPERS.");
            }
            else
            {
                
wspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {a1f406}You are now spying on WHISPERS.");
            }
        }
    }
    return 
1;

*Whole source code:
PHP Code:
//Whisper, Car Whsiper simple systems, with some administration control.
//Made by RxErT

//===Includes===//
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//-------------//

//===Variables===//
new wspy[MAX_PLAYERS];
new 
cwspy[MAX_PLAYERS];
new 
pmspy[MAX_PLAYERS];
new 
IsSpawned[MAX_PLAYERS];
//=================//

public OnPlayerConnect(playerid)
{
   
IsSpawned[playerid] = 0;
   
wspy[playerid] = 0;
   
cwspy[playerid] = 0;
   
pmspy[playerid] = 0;
   return 
1;
}

public 
OnPlayerSpawn(playerid)
{
   
IsSpawned[playerid] = 1;
   return 
1;
}

/*Car Whisper*/
CMD:cw(playeridparams[])
{
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        new 
string[250], textes[120], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridname,sizeof(name));

        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/cw <message>");
        }
        else
        {
            if(
IsPlayerInAnyVehicle(playerid))
            {
                new 
vehicleID GetPlayerVehicleID(playerid);

                new 
string2[250];
                
format(string2sizeof(string2), "{adf407}[Car Whisper] {FFFFFF}%s(%i): {adf407}%s",nameplayeridstring);

                for(new 
0<= MAX_PLAYERSi++)
                {
                    if(
IsPlayerInVehicle(ivehicleID))
                    {
                        
SendClientMessage(i, -1string2);
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid,0xf8f8f8fff"ERROR: {F00f00}You are not in a vehicle.");
            }
            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerInAnyVehicle(playerid))
                    {
                        if (
IsPlayerAdmin(i))
                        {
                            if (
cwspy[i])
                            {
                                new 
cwtext[200];
                                
format(cwtextsizeof(cwtext), "{f00f00}[Car Whisper SPY]>> %s: %s",namestringtextes);
                                
SendClientMessage(i, -1cwtext);
                            }
                          }
                      }
                }
            }
        }
        return 
1;
}
/* Car Whisper Spying */
CMD:cwspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
cwspy[playerid])
            {
                
cwspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are not spying on car whisper.");
            }
            else
            {
                
cwspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {adf407}You are now spying on car whisper.");
            }
        }
    }
    return 
1;
}
/*Done*/




/* Whisper */
CMD:w(playeridparams[])
{
        new 
string[250];
        new 
nameplaya[MAX_PLAYER_NAME];
        new 
textes2[120];
        
GetPlayerName(playeridnameplaya,sizeof(nameplaya));
        if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
        if (
sscanf(params"s[250]"string))
        {
            
SendClientMessage(playerid0xf8f8f8fff"Syntax: {f48006}/(w)hisper <message>");
        }
        else
        {
            new 
Float:x,Float:y,Float:z;
            
GetPlayerPos(playerid,x,y,z);

            new 
string2[250];
            
format(string2sizeof(string2), "{f47e07}[WHISPER] {FFFFFF}%s(%i): {f47e07}%s",nameplayaplayeridstring);

            for(new 
0<= MAX_PLAYERSi++)
            {
                if(
IsPlayerInRangeOfPoint(i15.0xyz))
                {
                    
SendClientMessage(i, -1string2);
                    
PlayerPlaySound(i1085,0.0,0.0,0.0);
                }
                 if(
IsPlayerConnected(i))
                {
                    if(
IsPlayerAdmin(i))
                    {
                         if (
wspy[i])
                        {
                        new 
wtext[200];
                        
format(wtextsizeof(wtext), "{f904e9}[WHISPER SPY]> {FFFFFF}%s: %s",nameplayastringtextes2);
                        
SendClientMessage(i, -1wtext);
                        }
                    }
                }
            }
        }
        return 
1;
}

/* Whisper spy */
COMMAND:wspy(playeridparams[])
{
    if(
IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xf8f8f8fff,"ERROR: {f00f00}You should be spawned first!");
    if(
IsPlayerConnected(playerid))
    {
        if(
IsPlayerAdmin(playerid))
        {
            if (
wspy[playerid])
            {
                
wspy[playerid] = false;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {f41f07}You are no longer spying on WHISPERS.");
            }
            else
            {
                
wspy[playerid] = true;
                
SendClientMessage(playerid0xf8f8f8fff"[SERVER] {a1f406}You are now spying on WHISPERS.");
            }
        }
    }
    return 
1;
}
/* Done */ 
If you find anything strange feel free to remind me!
__________________
Filterscript:[UPDATED] DM Event [Friendly, Funny, Controllable]
Snippet:Whisper and Car whisper commands, controllable
Discord: Flofey#8478
Github: RxErT's profile
Working-on: Administration script Based on SQLite
RxErT is offline   Reply With Quote
Old 19/02/2018, 09:15 AM   #1258
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,472
Reputation: 291
Default Re: Useful Snippets

Putting this under OnPlayerConnect will kick many of the famous SA-MP hacked clients (ones with very dangerous cheats) including the famous raksamp.

PHP Code:
stock IsPlayerBot(playerid)
{  
    new 
TempId[80], TempNumb;  
    
gpci(playeridTempIdsizeof(TempId));  
    for(new 
0strlen(TempId); i++)  
    {  
        if(
TempId[i] >= '0' && TempId[i] <= '9')  TempNumb++;  
    }  
    return (
TempNumb >= 30 || strlen(TempId) <= 30) ? true false;

I'd say this is very important to use cuz it really did work against many hacked clients, you can try it yourself on your offline server before using it online.
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link





Last edited by RogueDrifter; 28/02/2018 at 01:07 PM.
RogueDrifter is offline   Reply With Quote
Old 28/02/2018, 12:55 PM   #1259
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,472
Reputation: 291
Default Re: Useful Snippets

This function will return true if the player is UNDER water and false if he isn't,
PHP Code:
stock IsPlayerUnderWater(playerid)
{
    new 
PPAnim GetPlayerAnimationIndex(playerid);
    return (
PPAnim == 1540 || PPAnim == 1544);

Very simple and basic but yeah didn't see it anywhere.
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link





Last edited by RogueDrifter; 09/04/2018 at 10:23 PM.
RogueDrifter is offline   Reply With Quote
Old 07/03/2018, 09:07 PM   #1260
RogerCosta
Huge Clucker
 
RogerCosta's Avatar
 
Join Date: Aug 2014
Location: Santos, Brazil.
Posts: 330
Reputation: 88
Default Re: Useful Snippets

Extra functions created by me for extract value from one key in Y_INI:

Code:
// Global variables
enum {
    INT,
    FLOAT,
    STRING
}

new key_name[50], 
    key_type, 
    key_value_int, 
    Float:key_value_float, 
    key_value_str[128];

stock INI_GetInt(filename[], key[], &variable) {
    INI_ParseFile(filename, "LoadOnlyKey", .bExtra = true, .bLocal = true); 
    format(key_name, sizeof key_name, "%s", key);
    key_type = INT;
    variable = key_value_int;
}

stock INI_GetFloat(filename[], key[], &Float:variable) {
    INI_ParseFile(filename, "LoadOnlyKey", .bExtra = true, .bLocal = true); 
    format(key_name, sizeof key_name, "%s", key);
    key_type = FLOAT;
    variable = key_value_float;
}

stock INI_GetString(filename[], key[], variable[]) {
    INI_ParseFile(filename, "LoadOnlyKey", .bExtra = true, .bLocal = true); 
    format(key_name, sizeof key_name, "%s", key);
    key_type = STRING;
    format(variable, sizeof variable, "%s", key_value_float);
}

forward LoadOnlyKey(name[], value[]) {}
public LoadOnlyKey(name[], value[]) {
    switch(key_type) {
        case STRING:    INI_String(key_name, key_value_str, sizeof key_value_str);
        case FLOAT:     INI_Float(key_name, key_value_float);
        case INT:       INI_Int(key_name, key_value_int);
    }
    return true;
}

Last edited by RogerCosta; 10/03/2018 at 03:20 AM.
RogerCosta 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
READ Usefull Links to snippets and other -Sneaky- Help Archive 5 02/05/2009 11:22 AM


All times are GMT. The time now is 01:06 AM.


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