Car lock question. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car lock question. (
/showthread.php?tid=88618)
Car lock question. -
Andron - 27.07.2009
Well, yeah. I have currently easy system. If player just type /car lock1, then his/her car will lock/unlock. Well, how I can put it like that way : Player can use /car lock1 cmd ONLY if he are close to his/her car? Can somebody tell me? Is its something like "Getplayerdistancetocar" or something like that?
Current system cmd.
Код:
else if(strcmp(x_nr,"lock1",true) == 0)
{
new keycar = PlayerInfo[playerid][pPcarkey];
if(keycar != 999)
{
new locked[256];
locked = strtok(cmdtext, idx);
if(CarInfo[keycar][cLock] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
SetVehicleParamsForPlayer(keycar,i,0,0);
}
}
format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
GameTextForPlayer(playerid, string, 4000, 3);
CarInfo[keycar][cLock] = 0;
OnPropUpdate();
return 1;
}
else if(CarInfo[keycar][cLock] == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
SetVehicleParamsForPlayer(keycar,i,0,1);
}
}
format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
GameTextForPlayer(playerid, string, 4000, 3);
CarInfo[keycar][cLock] = 1;
OnPropUpdate();
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 1");
return 1;
}
}
Re: Car lock question. -
MadeMan - 27.07.2009
You can use this:
pawn Код:
stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
Re: Car lock question. -
Andron - 27.07.2009
Well, tell me. How I can put this weird code to work?
Re: Car lock question. -
MadeMan - 27.07.2009
pawn Код:
new Float:px, Float:py, Float:pz, Float:cx, Float:cy, Float:cz;
GetPlayerPos(playerid, px, py, pz);
GetVehiclePos(vehicleid, cx, cy, cz);
GetDistanceBetweenPoints(px, py, pz, cx, cy, cz);