car sell checkpoint -
PSYCHOBABYKILLA - 29.03.2015
so ive been workin on this very basic script today because im a noob but anyways
Код:
public OnGameModeInit()
{
specialcar = CreateVehicle(415,2468.2800,-1655.1469,13.1312,149.1079,25,-1,-1); // dm2 car1
return 1;
}public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/vs", cmdtext,true, 10) == 0)
{
if(PlayerToPoint(5.0,playerid,2490.0757,-1662.8297,13.1110)) // 723.6520, -1890.7867, -0.0164 are the coord from your PirateShip(X,Y,Z) and 5.0 is the range between ship and player.
{
if(IsPlayerInVehicle(playerid, specialcar))
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
DestroyVehicle(vehicleid);
SendClientMessage(playerid, -1, "You have recieved $5000");
GameTextForPlayer(playerid, "VEHICLE SOLD", 3000, 5);
GivePlayerMoney(playerid, 5000);
DisablePlayerCheckpoint(playerid);
RemovePlayerMapIcon(playerid, 12);
}
}
else SendClientMessage(playerid, -1,"You're not near the Crane.");
return 1;
}
return 0;public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == specialcar)
{
SetPlayerMapIcon( playerid, 12, 2490.0757,-1662.8297,13.1110, 55, 0, MAPICON_GLOBAL );
SetPlayerCheckpoint(playerid, 2490.0757,-1662.8297,13.1110, 3.0);
return 1;
}
return 0;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == specialcar)
{
new string[35];
format(string, sizeof(string), "INFO: You are exiting vehicle %i", vehicleid);
SendClientMessage(playerid, 0xFFFFFFFF, string);
RemovePlayerMapIcon(playerid, 12);
DisablePlayerCheckpoint(playerid);
}
return 1;
}public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_SUBMISSION)
{
if(IsPlayerInVehicle(playerid, specialcar))
OnPlayerCommandText(playerid, "/vs");
//if /ticket is in another script, use:
//CallRemoteFunction("OnPlayerCommandText", "is", playerid, "/ticket");
return true;
}
return false;
}forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
theres nothing wrong with this it works fine but the problem is i try to add a second car and the checkpoint and map pops up but i keep messing up on the onplayercommandtext to add a duplicate of the car thats because i tried to add new specialcar2;
if i put both the cars at specialcar = createvehicle the command doesnt work at all
is there a better way of doing this because id rather do it for all the cars in the map but it will be a pain in the ass and a long ass code if i have to do this for every single car in the map
Re: car sell checkpoint -
Just1c3 - 29.03.2015
There's a vehicle array around. Loop through it and you will be able tot use it for all the vehicles.
Re: car sell checkpoint -
PSYCHOBABYKILLA - 29.03.2015
can somebody help me out ive been stuck on this for too long this is script is so noob it should require this much time worked on how can i get the second car to work
Re: car sell checkpoint -
Tanky - 29.03.2015
Create a global array: new specialcar[SPECIAl_CARS]; (define SPECIAl_CARS with the number of special cars you want to have)
Then under ongamemodeinit create all your special cars in that array starting with 0: specialcar[0] = CreateVehicle(...);
specialcar[1] = CreateVehicle(...) etc.
Then create a stock to check if the player is inside a special car.
Код:
stock IsPlayerInSpecialCar(playerid)
{
new const veh = GetPlayerVehicleID(playerid); //don't use const if you dont want, i just got used to using it
if(veh == INVALID_VEHICLE_ID) return false;
for(new i = 0; i < SPECIAL_CARS; i++)
{
if(specialcar[i] == veh) return true;
}
return false;
}
Then just use this function to check if he is in any of them.
Re: car sell checkpoint -
PSYCHOBABYKILLA - 29.03.2015
edit:
Код:
if(strcmp("/vs", cmdtext,true, 10) == 0)
{
if(PlayerToPoint(3.0,playerid,2490.0757,-1662.8297,13.1110)) // 723.6520, -1890.7867, -0.0164 are the coord from your PirateShip(X,Y,Z) and 5.0 is the range between ship and player.
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 415) //
{
DestroyVehicle(vehicleid);
SendClientMessage(playerid, -1, "You have recieved $5000");
GameTextForPlayer(playerid, "VEHICLE SOLD", 3000, 5);
GivePlayerMoney(playerid, 5000);
DisablePlayerCheckpoint(playerid);
RemovePlayerMapIcon(playerid, 12);
}
}
if(PlayerToPoint(3.0,playerid,2490.0757,-1662.8297,13.1110)) // 723.6520, -1890.7867, -0.0164 are the coord from your PirateShip(X,Y,Z) and 5.0 is the range between ship and player.
{
if(IsPlayerInVehicle(playerid, bullet))
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
if(vehicleid == bullet)
DestroyVehicle(vehicleid);
SendClientMessage(playerid, -1, "You have recieved $3000");
GameTextForPlayer(playerid, "VEHICLE SOLD", 3000, 5);
GivePlayerMoney(playerid, 3000);
DisablePlayerCheckpoint(playerid);
RemovePlayerMapIcon(playerid, 12);
}
}
else SendClientMessage(playerid, -1,"You're not near the Crane.");
return 1;
}
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 415)
fixed it got what i wanted done from this line getvehiclemodel thanks for the help