SA-MP Forums Archive
Need a small help with stock. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need a small help with stock. (/showthread.php?tid=579672)



Need a small help with stock. - Sc0pion - 29.06.2015

Fixed!


Re: Need a small help with stock. - BroZeus - 29.06.2015

PHP код:
stock IsPlayerAllowedToBuyHouse(playerid)
{
    new 
countname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    new 
score GetPlayerScore(playerid);//better to call func once rather than calling everytime for checking score.
    
if(score 1000)return false;//cant own any house if score is less than 1000
    
for(new 0MAX_HOUSES++)
    {
        
//you can return a value directly from loop no need for that 'break'
        
if(strcmp(hInfo[i][Owner], nametrue) == 0count ++;
        if(
count == 3)return false;   
    }
    if(
score 10000 && count == 0) return true;
    if(
score >= 10000 && score 20000 && count 2)return true;
    return 
true;




Re: Need a small help with stock. - Sc0pion - 29.06.2015

Fixed!


Re : Need a small help with stock. - AlexBlack - 29.06.2015

try to replace this :

PHP код:
        if(strcmp(hInfo[i][Owner], nametrue) == 0count ++; 
to
PHP код:
        if(!strcmp(hInfo[i][Owner], name)) count ++; 



Re: Re : Need a small help with stock. - Sc0pion - 29.06.2015

Fixed!


Re: Need a small help with stock. - Jefff - 29.06.2015

pawn Код:
stock IsPlayerAllowedToBuyHouse(playerid)
{
    new Score = GetPlayerScore(playerid);
    if(Score < 1000) return 0;

    new count, name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    for(new i = 0; i < MAX_HOUSES; i ++)
        if(hInfo[i][Owner][0] && strcmp(hInfo[i][Owner], name) == 0)
            if(++count >= 3) // player has got 3 houses
                return 0;

    if(Score < 10000 && !count) return 1;
    if(10000 <= Score < 20000 && count < 2) return 1;
    if(Score > 20000) return 1;
    return 0;
}



Re: Need a small help with stock. - Sc0pion - 29.06.2015

Fixed!