29.03.2015, 06:21
so ive been workin on this very basic script today because im a noob but anyways
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
Код:
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; }
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