Check player score :)
#3

Ever thought of using a 3-dimensional array?
Ex: PlayerInfo[playerid][vowner][0] to PlayerInfo[playerid][vowner][14].

pawn Код:
enum pInfo // or whatever you called it
{
    vowner[15],
    vowned[15],
}
Calculating the amount of buyable cars is also not hard. You just need some very basic math skills.
pawn Код:
new
    cars = (GetPlayerScore(playerid) / 100) - 1;
    // I do -1 here to find the right index for the array. If it returns -1, then the score is < 100
   
    cars = (cars > 15) ? 15 : cars;
    // Adding this so array index won't go out of bounds when score is > 1500

if(cars < 0)
    return SendClientMessage(playerid, COLOR_RED, "Your score is not high enough to be able to buy a car.");

// now find amount of cars already owned
new
    i, count, freeslot = -1;

for(i = 0, i < 15; i++)
{
    if(PlayerInfo[playerid][vowner][i])
    {
        count++;
    }
    else
    {
        freeslot = i; // find free slot to store new car
    }
}

if((cars - count) <= 0 || count >= 15 || freeslot == -1)
    return SendClientMessage(playerid, COLOR_RED, "You cannot own anymore cars");

PlayerInfo[playerid][vowner][freeslot] = 1;
PlayerInfo[playerid][vowned][freeslot] = GetPlayerVehicleID(playerid);
Reply


Messages In This Thread
[HELP]Players must do score to buy cars :) I really need help ! - by sMog. - 16.04.2011, 13:47
Re: Check player score :) - by sMog. - 16.04.2011, 15:13
Re: Check player score :) - by Vince - 16.04.2011, 15:38
Re: Check player score :) - by sMog. - 16.04.2011, 15:50
Re: Check player score :) - by sMog. - 16.04.2011, 23:32
Re: Check player score :) - by iJumbo - 17.04.2011, 11:31
Re: Check player score :) - by sMog. - 17.04.2011, 11:35

Forum Jump:


Users browsing this thread: 1 Guest(s)