Problem Get Player in personal vehicle - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem Get Player in personal vehicle (
/showthread.php?tid=661214)
Problem Get Player in personal vehicle -
rollercaster - 26.11.2018
When I'm in my personal car it goes but
when in another car it does not work..
Image:
and on the server looks: SERVER: Unknown command.
My Code:
Код HTML:
stock CarOwner3(playerid, vehicleid)
{
if( CarInfo[PlayerInfo[playerid][pCarPers][0]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][0]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][1]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][1]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][2]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][2]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][3]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][3]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][4]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][4]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][5]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][5]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][6]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][6]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][7]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][7]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][8]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][8]][cSpawn])
{
return 1;
}
else if( CarInfo[PlayerInfo[playerid][pCarPers][9]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][9]][cSpawn])
{
return 1;
}
return 0;
}
CMD:park(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not in your personal vehicle!");
new getcarid = GetPlayerVehicleID(playerid);
if(IsPlayerConnected(playerid))
{
if(CarOwner3(playerid, getcarid)) // checking whether the player is in the personal car
{
PersonalCars(playerid, 2, getcarid); // In personal vehicle
}
else
{
SCM(playerid, -1, "[Personal Car's]: You are not in your personal vehicle!");
}
}
return 1;
}
Re: Problem Get Player in personal vehicle -
rollercaster - 27.11.2018
Help me
Re: Problem Get Player in personal vehicle -
AmirSavand - 27.11.2018
You're accessing an array with an invalid index, show the line number and the line where the backtracke is showing you.
Re: Problem Get Player in personal vehicle -
rollercaster - 29.11.2018
Код HTML:
enum pInfo
{
pCarPers[10]
};
new PlayerInfo[MAX_PLAYERS][pInfo];
enum cInfo
{
cID,
cModel,
cSpawn
};
new CarInfo[2000][cInfo];
Re: Problem Get Player in personal vehicle -
Kaliber - 30.11.2018
You can write your hole code like this:
That makes it a lot easier.
Код:
stock CarOwner3(playerid, vehicleid)
{
for(new i,idx; i<10; i++)
{
idx = PlayerInfo[playerid][pCarPers][i];
if(idx != -1 && vehicleid == CarInfo[idx][cSpawn]) return 1;
}
return 0;
}
CMD:park(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not in your personal vehicle!");
new getcarid = GetPlayerVehicleID(playerid);
if(CarOwner3(playerid, getcarid)) // checking whether the player is in the personal car
{
PersonalCars(playerid, 2, getcarid); // In personal vehicle
}
else
{
SCM(playerid, -1, "[Personal Car's]: You are not in your personal vehicle!");
}
return 1;
}
Re: Problem Get Player in personal vehicle -
rollercaster - 30.11.2018
I did well?
To return pcarkey id ( PlayerInfo[playerid][pCarPers][0], PlayerInfo[playerid][pCarPers][1], etc.. )
it is possible for multiple players to have trouble checking?
Код HTML:
stock CarOwner2(playerid, vehicleid)
{
new CarKeY = 0;
for(new i = 0; i < 10; i++)
{
if(CarInfo[PlayerInfo[playerid][pCarPers][i]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][i]][cSpawn])
{
CarKeY = PlayerInfo[playerid][pCarPers][i];
break;
}
}
return CarKeY;
}