strcmp
#3

Quote:
Originally Posted by Kaliber
View Post
Because you have to check all players first.

Use a function like that:

PHP Code:
Dialog:DialogATM4(playeridresponselistiteminputtext[])
{
    if(!
response) return 1;
    new 
sb_string[256], AmountPool GetPVarInt(playerid"atm_cash");
    
GetPVarString(playerid"atm_name_target"sb_stringsizeof(sb_string));
    
    
//You should Free the PVar Storage!
    
DeletePVar(playerid,"atm_cash");
    
DeletePVar(playerid"atm_name_target");
    
    if(
User[playerid][pbank] < AmountPool) return Error(playerid"Shoma In Moghdar Pool Ra Dar Hesab Banki Khod Nadrid!");
    
    new 
IsPlayerOnline(sb_string);
    if(
i!=INVALID_PLAYER_ID)
    { 
//If Online
        
SendFormatedMessage(i,-1"**"orange"Bazikon %s(%i) Moghdare "white"%i$ "orange"Rial Pool Be Hesab Banki Shoma Variz Kard!"GetName(playerid),playerid,AmountPool);
        
PlayerPlaySound(i10570.00.010.0);
        
User[i][pbank] += AmountPool;
    }
    else
    { 
//If Not Online
        
new strb SQL::GetIntEntryEx(""PLAYERS_TABLE"""pbank""username"sb_string);
        new 
handle SQL::OpenEx(SQL::UPDATE""PLAYERS_TABLE"""username"sb_string);
        
SQL::WriteInt(handle"pbank"strb+TargetATMCash[playerid]+AmountPool);
        
SQL::Close(handle);
    }
    
PlayerPlaySound(playerid10570.00.010.0);
    
User[playerid][pbank] -= AmountPool;
    
SendFormatedMessage(playeridCOLOR_ORANGE,"*Shoma Mablagh %i Pool Be Hesab Banki Bazikon %s Variz Kardid!",AmountPool,sb_string);
    return 
1;
}
stock IsPlayerOnline(const name[])
{
    for(new 
i=GetPlayerPoolSize(); i!=-1i--)
    {
        if(
IsPlayerConnected(i) && !strcmp(name,GetName(i))) return i;
    }
    return 
INVALID_PLAYER_ID;

Tnx
+rep
Reply


Messages In This Thread
strcmp - by Vizi10 - 18.01.2019, 10:13
Re: strcmp - by Kaliber - 18.01.2019, 11:00
Re: strcmp - by Vizi10 - 18.01.2019, 14:34

Forum Jump:


Users browsing this thread: 1 Guest(s)