strcmp
#1

I want if player name is online tarnsfer the cash into player account bank but strcmp not working
why?

Code:
Dialog:DialogATM4(playerid, response, listitem, inputtext[])
{
	if(response)
	{
        new sb_string[256];
        new AmountPool = GetPVarInt(playerid, "atm_cash");
        if(User[playerid][pbank] > AmountPool)
        {
        GetPVarString(playerid, "atm_name_target", sb_string, sizeof(sb_string));
	LOOP(i)
	{
	    if(!strcmp(sb_string, GetName(i), false))
	    { 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(i, 1057, 0.0, 0.0, 10.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(playerid, 1057, 0.0, 0.0, 10.0);
	User[playerid][pbank] -= AmountPool;
	SendFormatedMessage(playerid, COLOR_ORANGE,"*Shoma Mablagh %i Pool Be Hesab Banki Bazikon %s Variz Kardid!",AmountPool,sb_string);
	
    } else return Error(playerid, "Shoma In Moghdar Pool Ra Dar Hesab Banki Khod Nadrid!");
    }
    return 1;
}
Reply
#2

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;

Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)