09.04.2013, 13:51
Okay let's get straight to it. I load the info from my DB(no problem here) and then I create a vehicle like this:
That works,the car appears.
The problem is in my park function:
And when i test it IG, i spawn 2 cars, and i can only park the last one spawned.
That should loop trough max player spawned vehicles,which is 2. That works I think.
At first i=0. So and that shouldn't be the currentveh,because PlayerVehiclesSpawned[playerid] is by deffault 0 and on spawn it add 1 to it. So the loop does i=1, that SHOULD park the vehicle because on spawn PlayerVehiclesSpawned[playerid] was 1. So what is the problem?
I really hope you understand what I mean.
pawn Код:
Keys[VehicleKeys[playerid]][PlayerVehiclesSpawned[playerid]+1] = CreateVehicle(VehicleInfo[VehicleKeys[playerid]][model],VehicleInfo[VehicleKeys[playerid]][X],VehicleInfo[VehicleKeys[playerid]][Y],VehicleInfo[VehicleKeys[playerid]][Z],VehicleInfo[VehicleKeys[playerid]][R],VehicleInfo[VehicleKeys[playerid]][CColor1],VehicleInfo[VehicleKeys[playerid]][CColor2],-1);
The problem is in my park function:
pawn Код:
if(!strcmp(tmp,"park",true,4))
{
new currentveh;
if(IsPlayerInAnyVehicle(playerid))
{
currentveh = GetPlayerVehicleID(playerid);
GetPlayerName(playerid,Name,sizeof(Name));
if(IsPlayerInRangeOfPoint(playerid,5,VehicleInfo[VehicleKeys[playerid]][X],VehicleInfo[VehicleKeys[playerid]][Y],VehicleInfo[VehicleKeys[playerid]][Z]))
{
for(new i=0; i<MAX_PLAYER_SPAWNED_VEHICLES; i++)
{
if(currentveh == Keys[VehicleKeys[playerid]][i])
{
DestroyVehicle(currentveh);
PlayerVehiclesSpawned[playerid]--;
SendClientMessage(playerid,0x00FF00,"Masina priparkuota");
}
}
}
}
}
That should loop trough max player spawned vehicles,which is 2. That works I think.
At first i=0. So and that shouldn't be the currentveh,because PlayerVehiclesSpawned[playerid] is by deffault 0 and on spawn it add 1 to it. So the loop does i=1, that SHOULD park the vehicle because on spawn PlayerVehiclesSpawned[playerid] was 1. So what is the problem?
I really hope you understand what I mean.