Vehicles Slots Per 1Player
#1

hello ^_^
i want know somthing
how i can make Slots Per 1Player For Buying new Vehicles
i tired too making it 5 slots but when i buying this my problems becuse when i buying all saving only in First Slots
please need help!
+Rep
Reply
#2

Something of this nature should be sufficient.

Код:
new vSlots[MAX_PLAYERS][5];

for (new x = 0; x < 5; x++)
{
	if (vSlots[playerid][x] == 0)
	{
		//store vehicle here
		break;
	}
}
Reply
#3

Quote:
Originally Posted by LEOTorres
Посмотреть сообщение
Something of this nature should be sufficient.

Код:
new vSlots[MAX_PLAYERS][5];

for (new x = 0; x < 5; x++)
{
	if (vSlots[playerid][x] == 0)
	{
		//store vehicle here
		break;
	}
}
PHP код:
enum InfoVehicles
{
    
vehicle,
    
model,
    
world,
    
interior,
    
Float:x_,
    
Float:y_,
    
Float:z_,
    
Float:angel_,
    
    
vehicle1,
    
model1,
    
world1,
    
interior1,
    
Float:x_1,
    
Float:y_1,
    
Float:z_1,
    
Float:angel_1,
    
    
vehicle2,
    
model2,
    
world2,
    
interior2,
    
Float:x_2,
    
Float:y_2,
    
Float:z_2,
    
Float:angel_2,
    
    
vehicle3,
    
model3,
    
world3,
    
interior3,
    
Float:x_3,
    
Float:y_3,
    
Float:z_3,
    
Float:angel_3,
    
    
vehicle4,
    
model4,
    
world4,
    
interior4,
    
Float:x_4,
    
Float:y_4,
    
Float:z_4,
    
Float:angel_4,
};
CMD:carsss(playeridparams[])
{
    if(
sscanf(params"i"params[0]))
        return 
SendClientMessage(playerid, -1"usage: /cars [vehicle 1-7].");
    if(
vInfo[playerid][vehicle] != 0)
    {
        
DestroyVehicle(vInfo[playerid][vehicle]);
    }
    
//..
    
new Float:pos[5];
    
GetVehicleZAngle(playeridpos[4]);
    
GetPlayerFacingAngle(playeridpos[3]);
    
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
    
//..
    
switch(params[0])
    {
        case 
1:
        {
            if(
GetPlayerMoney(playerid) < 1200000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(541pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -1200000);
            
vInfo[playerid][model] = 541;
        }
        case 
2:
        {
            if(
GetPlayerMoney(playerid) < 1900000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(411pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -1900000);
            
vInfo[playerid][model] = 411;
        }
        case 
3:
        {
            if(
GetPlayerMoney(playerid) < 4000000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(494pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -4000000);
            
vInfo[playerid][model] = 494;
        }
        case 
4:
        {
            if(
GetPlayerMoney(playerid) < 22000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(409pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -22000);
            
vInfo[playerid][model] = 409;
        }
        case 
5:
        {
            if(
GetPlayerMoney(playerid) < 460000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(560pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -460000);
            
vInfo[playerid][model] = 560;
        }
        case 
6:
        {
            if(
GetPlayerMoney(playerid) < 600000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(506pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -600000);
            
vInfo[playerid][model] = 506;
        }
        case 
7:
        {
            if(
GetPlayerMoney(playerid) < 5000000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
vInfo[playerid][vehicle] = CreateVehicle(521pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -5000000);
            
vInfo[playerid][model] = 521;
        }
    }
    return 
true;

can you example it to me please!!
Reply
#4

That is because you are saving it to the first slot. The tag [vehicle] refers to the first slot. No matter what car you buy, You're always assigning it to the first slot. Look at the code:

PHP код:
vInfo[playerid][vehicle
That's the first slot. To fix this, You need to loop through the vehicle slots and get the empty slot.
And then assign the create vehicle to that.
Reply
#5

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
That is because you are saving it to the first slot. The tag [vehicle] refers to the first slot. No matter what car you buy, You're always assigning it to the first slot. Look at the code:

PHP код:
vInfo[playerid][vehicle
That's the first slot. To fix this, You need to loop through the vehicle slots and get the empty slot.
And then assign the create vehicle to that.
i can make
PHP код:
vInfo[5][playerid][vehicle
to accept my 5 slots ? per 1player
Reply
#6

Quote:
Originally Posted by se3a
Посмотреть сообщение
i can make
PHP код:
vInfo[5][playerid][vehicle
to accept my 5 slots ? per 1player
Do you know anything about scripting? I'm assuming not. That's not how it works. You must've just copy pasted the script. Try to understand what's going on. You already added vehicle1-4 in your Enum. Now you just have to loop through them. I suggest you to read some tutorials, Understand what's going on and try to make it your own. Instead of just copy/pasting.
Reply
#7

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
Do you know anything about scripting? I'm assuming not. That's not how it works. You must've just copy pasted the script. Try to understand what's going on. You already added vehicle1-4 in your Enum. Now you just have to loop through them. I suggest you to read some tutorials, Understand what's going on and try to make it your own. Instead of just copy/pasting.
excuse
if im copy / paste
i will not trying to make this system u see it
excuse again
all my problems i'm new and i know much somthings from wiki and TUT
i just not see somone make it like me
just this my problems
PHP код:
            vInfo[playerid][vehicle] = CreateVehicle(411pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
            
GivePlayerMoney(playerid, -1900000);
            
vInfo[playerid][model] = 411
i want making it with my enum and you can see the changed from my enum
i cant know how too createvehicle with my way and u see my enum
where is copy / paste here ?
Reply
#8

Okay, So first you change your ENUM to this:

PHP код:
enum InfoVehicles
{
    
vehicle[4],
    
model[4],
    
world[4],
    
interior[4],
    
Float:x_[4],
    
Float:y_[4],
    
Float:z_[4],
    
Float:angel_[4],
}; 
This is waaay easier. Now if you want to access the slots it would be like this:
PHP код:
vInfo[playerid][vehicle][0] = ... //Slot 1
vInfo[playerid][vehicle][1] = ... //Slot 2
vInfo[playerid][vehicle][2] = ... //Slot 3
vInfo[playerid][vehicle][3] = ... //Slot 4
vInfo[playerid][vehicle][4] = ... //Slot 5 
But doing this would mean you have to change your whole script!!!!!
Reply
#9

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
Okay, So first you change your ENUM to this:

PHP код:
enum InfoVehicles
{
    
vehicle[4],
    
model[4],
    
world[4],
    
interior[4],
    
Float:x_[4],
    
Float:y_[4],
    
Float:z_[4],
    
Float:angel_[4],
}; 
This is waaay easier. Now if you want to access the slots it would be like this:
PHP код:
vInfo[playerid][vehicle][0] = ... //Slot 1
vInfo[playerid][vehicle][1] = ... //Slot 2
vInfo[playerid][vehicle][2] = ... //Slot 3
vInfo[playerid][vehicle][3] = ... //Slot 4
vInfo[playerid][vehicle][4] = ... //Slot 5 
But doing this would mean you have to change your whole script!!!!!
okay dude thank you i will trying with this way ^_^
Reply
#10

Quote:
Originally Posted by se3a
Посмотреть сообщение
okay dude thank you i will trying with this way ^_^
Glad to know. I made a Vehicle system. You can refer to it if you would like to:

https://sampforum.blast.hk/showthread.php?tid=615531
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)