Need a small help with stock.
#1

Fixed!
Reply
#2

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;

Reply
#3

Fixed!
Reply
#4

try to replace this :

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

Fixed!
Reply
#6

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

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)