Check player score :)
#1

Hello how to edit this like if you have score about 100 you can buy on car if 300 you can buy 2 cars and so on full table:
1. = 100
2. = 100 + 200 = 300
3. = 300 + 300 = 600
4. = 600 + 400 = 1000
5. = 1000 + 500 = 1500
6. = 1500 + 600 = 2100
7. = 2100 + 700 = 2800
8. = 2800 + 800 = 3600
9. = 3600 + 900 = 4500
10. = 4500 + 1000 = 5500
11. = 5500 + 1100 = 6600
12. = 6600 + 1200 = 7800
13. = 7800 + 1300 = 9100
14. = 9100 + 1400 = 10500
15. = 10500 + 1500 = 12000

EDIT: i added whole buycar
PHP код:
stock buycar(playerid)
{
    new 
string[128];
    if(
VehicleInfo[GetPlayerVehicleID(playerid)][Temp] == 1) {
        return 
SendClientMessage(playeridCOLOR_ORANGE"This vehicle is only temporary and some commands may not work!");
    }
    if(
PlayerInfo[playerid][LoggedIn] == 0) {
        
SendClientMessage(playeridCOLOR_BRIGHTRED"You must be logged in to use this feature");
        return 
1;
    }
    if(
PlayerInfo[playerid][Jailed] == 1) {
        
SendClientMessage(playeridCOLOR_BRIGHTRED"You are in jail and cannot use this feature");
        return 
1;
    }
    if(
passenger[playerid] == 1) {
        
SendClientMessage(playeridCOLOR_BRIGHTRED"You must be in the drivers' seat of this vehicle to buy it!");
        return 
1;
    }
    if(
IsPlayerInAnyVehicle(playerid) == 0) {
        
SendClientMessage(playeridCOLOR_BRIGHTRED"You must be in a vehicle in order to buy one!");
        return 
1;
    }
    if(
VehicleInfo[GetPlayerVehicleID(playerid)][buybar] == 1) {
        
SendClientMessage(playeridCOLOR_BRIGHTRED"This vehicle is currently set as un-buyable!");
        return 
1;
    }
    if (
strcmp(VehicleInfo[GetPlayerVehicleID(playerid)][owner],PlayerInfo[playerid][name],false) == 0) {
        
format(stringsizeof(string), "You already own this %s, %s"VehicleInfo[GetPlayerVehicleID(playerid)][name], PlayerInfo[playerid][name]);
        
SendClientMessage(playeridCOLOR_BRIGHTREDstring);
        return 
1;
    }
    if(
VehicleInfo[GetPlayerVehicleID(playerid)][bought] == 1) {
        
format(stringsizeof(string), "This %s is owned by %s, and is not for sale!"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][owner]);
        
SendClientMessage(playeridCOLOR_BRIGHTREDstring);
        return 
1;
    }
    if((
PlayerInfo[playerid][vowner] == 1) && (PlayerInfo[playerid][vowner2] == 1) && (PlayerInfo[playerid][vowner3] == 1) && (PlayerInfo[playerid][vowner4] == 1) && (PlayerInfo[playerid][vowner5] == 1) && (PlayerInfo[playerid][vowner6] == 1) && (PlayerInfo[playerid][vowner7] == 1) && (PlayerInfo[playerid][vowner8] == 1)){
        if((
PlayerInfo[playerid][vowner9] == 1) && (PlayerInfo[playerid][vowner10] == 1) && (PlayerInfo[playerid][vowner11] == 1) && (PlayerInfo[playerid][vowner12] == 1) && (PlayerInfo[playerid][vowner13] == 1) && (PlayerInfo[playerid][vowner14] == 1) && (PlayerInfo[playerid][vowner15] == 1)) {
            
SendClientMessage(playeridCOLOR_BRIGHTRED"You can only own FIFTEEN vehicles at a time! You must sell one other vehicle first!");
            return 
1;
        }
    }
    new 
cash[MAX_PLAYERS];
    
cash[playerid] = GetPlayerMoney(playerid);
    if(
cash[playerid] >= VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost]) {
        new 
stringa[128];
        
strmid(VehicleInfo[GetPlayerVehicleID(playerid)][owner], PlayerInfo[playerid][name], 0strlen(PlayerInfo[playerid][name]), 255);
        
VehicleInfo[GetPlayerVehicleID(playerid)][bought] = 1;
        if(
PlayerInfo[playerid][vowner] == 0){
            
PlayerInfo[playerid][vowner] = 1;
            
PlayerInfo[playerid][vowned] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #1"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner2] == 0){
            
PlayerInfo[playerid][vowner2] = 1;
            
PlayerInfo[playerid][vowned2] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #2"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner3] == 0){
            
PlayerInfo[playerid][vowner3] = 1;
            
PlayerInfo[playerid][vowned3] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #3"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner4] == 0){
            
PlayerInfo[playerid][vowner4] = 1;
            
PlayerInfo[playerid][vowned4] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #4"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner5] == 0){
            
PlayerInfo[playerid][vowner5] = 1;
            
PlayerInfo[playerid][vowned5] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #5"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner6] == 0){
            
PlayerInfo[playerid][vowner6] = 1;
            
PlayerInfo[playerid][vowned6] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #6"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner7] == 0){
            
PlayerInfo[playerid][vowner7] = 1;
            
PlayerInfo[playerid][vowned7] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #7"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner8] == 0){
            
PlayerInfo[playerid][vowner8] = 1;
            
PlayerInfo[playerid][vowned8] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #8"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner9] == 0){
            
PlayerInfo[playerid][vowner9] = 1;
            
PlayerInfo[playerid][vowned9] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #9"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner10] == 0){
            
PlayerInfo[playerid][vowner10] = 1;
            
PlayerInfo[playerid][vowned10] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #10"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner11] == 0){
            
PlayerInfo[playerid][vowner11] = 1;
            
PlayerInfo[playerid][vowned11] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #11"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner12] == 0){
            
PlayerInfo[playerid][vowner12] = 1;
            
PlayerInfo[playerid][vowned12] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #12"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner13] == 0){
            
PlayerInfo[playerid][vowner13] = 1;
            
PlayerInfo[playerid][vowned13] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #13"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner14] == 0){
            
PlayerInfo[playerid][vowner14] = 1;
            
PlayerInfo[playerid][vowned14] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #14"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner15] == 0){
            
PlayerInfo[playerid][vowner15] = 1;
            
PlayerInfo[playerid][vowned15] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #15"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        
GivePlayerMoney(playerid, -VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost]);
        
SavePlayer(playerid);
        return 
1;
    }
    if(
cash[playerid] < VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost]) {
        new 
string6[129];
        
format(string6sizeof(string6), "You do not have $%d and cannot afford this %s!"VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
        
SendClientMessage(playeridCOLOR_BRIGHTREDstring6);
        return 
1;
    }
    return 
1;

edit 2 is this right ?

PHP код:
new cash[MAX_PLAYERS];
    
cash[playerid] = GetPlayerMoney(playerid);
    if(
cash[playerid] >= VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost]) {
        new 
stringa[128];
        
strmid(VehicleInfo[GetPlayerVehicleID(playerid)][owner], PlayerInfo[playerid][name], 0strlen(PlayerInfo[playerid][name]), 255);
        
VehicleInfo[GetPlayerVehicleID(playerid)][bought] = 1;
        if(
PlayerInfo[playerid][vowner] == 0)|| GetPlayerscore(playerid) >= 100){
            
PlayerInfo[playerid][vowner] = 1;
            
PlayerInfo[playerid][vowned] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #1"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        }
        else if(
PlayerInfo[playerid][vowner2] == 0)|| GetPlayerscore(playerid) >= 200){
            
PlayerInfo[playerid][vowner2] = 1;
            
PlayerInfo[playerid][vowned2] = GetPlayerVehicleID(playerid);
            
format(stringasizeof(stringa), "You just bought this %s for $%d. In Car Calling Slot #2"VehicleInfo[GetPlayerVehicleID(playerid)][name], VehicleInfo[GetPlayerVehicleID(playerid)][vehiclecost],VehicleInfo[GetPlayerVehicleID(playerid)][name]);
            
SendClientMessage(playeridCOLOR_GREENstringa);
        } 
Or i must edit this ?
Код:
if((PlayerInfo[playerid][vowner] == 1) && (PlayerInfo[playerid][vowner2] == 1) && (PlayerInfo[playerid][vowner3] == 1) && (PlayerInfo[playerid][vowner4] == 1) && (PlayerInfo[playerid][vowner5] == 1) && (PlayerInfo[playerid][vowner6] == 1) && (PlayerInfo[playerid][vowner7] == 1) && (PlayerInfo[playerid][vowner8] == 1)){
	    if((PlayerInfo[playerid][vowner9] == 1) && (PlayerInfo[playerid][vowner10] == 1) && (PlayerInfo[playerid][vowner11] == 1) && (PlayerInfo[playerid][vowner12] == 1) && (PlayerInfo[playerid][vowner13] == 1) && (PlayerInfo[playerid][vowner14] == 1) && (PlayerInfo[playerid][vowner15] == 1)) {
			SendClientMessage(playerid, COLOR_BRIGHTRED, "You can only own FIFTEEN vehicles at a time! You must sell one other vehicle first!");
			return 1;
		}
	}
Reply
#2

why nobody helps me ?
Reply
#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
#4

okey i dont understand nofting

But thanks for help can u contact me

msn : poissalan@hotmail.com ?
or skype poissalan11

do i have to change all user files to add

Freeslot = 1 ?

my:
pawn Код:
enum pInfo;
{
    vowner,
    vowned2,
    vowner2,
    vowned3,
    vowner3,
    vowned4,
    vowner4,
    vowned5,
    vowner5,
    vowned6,
    vowner6,
    vowned7,
    vowner7,
    vowned8,
    vowner8,
    vowned9,
    vowner9,
    vowned10,
    vowner10,
    vowned11,
    vowner11,
    vowned12,
    vowner12,
    vowned13,
    vowner13,
    vowned14,
    vowner14,
    vowned15,
    vowner15,
}
And where i add score i want to make like
1. = 100
2. = 100 + 200 = 300
3. = 300 + 300 = 600
4. = 600 + 400 = 1000
5. = 1000 + 500 = 1500
6. = 1500 + 600 = 2100
7. = 2100 + 700 = 2800
8. = 2800 + 800 = 3600
9. = 3600 + 900 = 4500
10. = 4500 + 1000 = 5500
11. = 5500 + 1100 = 6600
12. = 6600 + 1200 = 7800
13. = 7800 + 1300 = 9100
14. = 9100 + 1400 = 10500
15. = 10500 + 1500 = 12000

and how to change all users that dosend have that much score : server sells they cars ?
i ahve command reset all vehicles but i dont want to sell all
Reply
#5

okey i get it like that

Код:
if(GetPlayerScore(playerid) < 100) {
		SendClientMessage(playerid, COLOR_BRIGHTRED, "You score must be atleast 100 to buy vehicle!");
		return 1;
	}
	if((PlayerInfo[playerid][vowner] == 1) && (GetPlayerScore(playerid) < 300)) {
		SendClientMessage(playerid, COLOR_BRIGHTRED, "You score must be atleast 300 to second buy vehicle!");
		return 1;
	}
but if i have scoer 100 i cant buy still first vehile
Reply
#6

make like if(GetPlayerScore(playerid) > 100) && GetPlayerScore(playerid) <= 300))
Reply
#7

so if i do like that it works ?
like i can buy i car 100 score ? 2 cars with 300 score ?

NO ONE CAN HELP ME ?!?! I REALLY NEED HELP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)