14.03.2011, 08:13
I use this command
new vehid = GetPlayerVehicleID(playerid);
if(strcmp(cmd,"/v",true)==0)
{
// new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
format(string,sizeof(string),"________________%s__ ______________",CarInfo[CheckOwner(playerid)][cDescription]);
SendClientMessage(playerid, COLOR_GREEN,string);
SendClientMessage(playerid, COLOR_GRAD2,"** /v buy - Buys the car (if for sale)");
SendClientMessage(playerid, COLOR_GRAD2,"** /v sell - Sells the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v park - Park the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v exit - Exit the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v locate - Uses the car's On-Star to locate");
SendClientMessage(playerid, COLOR_GRAD2,"** /v lock - Locks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v unlock - Unlocks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v autolock - Automatically locks the car upon exiting");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GRAD2,"** You do not currently own a car! **");
return 1;
}
}
return 1;
}
if(strcmp(tmp,"exit",true)==0)
{
CarOffered[playerid]=0;
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}
if(strcmp(tmp, "buy", true) == 0)
{
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][ownedvehicle] == vehid)
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /v sell if you want to buy this one!");
return 1;
}
if(CarInfo[i][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
{
PlayerInfo[playerid][pCarKey] = i;
CarInfo[i][cOwned] = 1;
CarOffered[playerid]=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[i][cValue]);
GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /v(ehicles) to view the car manual!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have the cash for that!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(tmp, "sell", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
return 1;
}
if(PlayerInfo[playerid][pCarKey] != 0 && strcmp(playername, CarInfo[PlayerInfo[playerid][pCarKey]][cOwner], true) == 0)
{
new car = PlayerInfo[playerid][pCarKey];
CarInfo[car][cOwned] = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[car][cOwner], "Dealership", 0, strlen("Dealership"), 999);
GivePlayerMoney(playerid,CarInfo[car][cValue]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", CarInfo[car][cValue]);
GameTextForPlayer(playerid, string, 10000, 3);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
PlayerInfo[playerid][pCarKey] = 0;
return 1;
}
}
return 1;
}
if(strcmp(tmp,"park",true) == 0)
{
new Float,Float:y,Float:z;
new Float:a;
// new carid;
new getcarid;
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pCarKey]) { carid = PlayerInfo[playerid][pCarKey]; }
else { return 1; }
getcarid = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
GetVehiclePos(carid, x, y, z);
//GetPlayerFacingAngle(playerid, a);
GetVehicleZAngle(carid, a);
if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
{
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
return 1;
}
if(getcarid == carid)
{
CarInfo[carid][cLocationx] = x;
CarInfo[carid][cLocationy] = y;
CarInfo[carid][cLocationz] = z;
CarInfo[carid][cAngle] = a;
format(string, sizeof(string), "~n~ You have parked your vehicle in this location. ~n~");
GameTextForPlayer(playerid, "You have parked your vehicle in this position. It will respawn here.", 10000, 3);
DestroyVehicle(carid);
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
TogglePlayerControllable(playerid, 1);
return 1;
}
}
}
if(strcmp(tmp, "locate", true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
if(PlayerInfo[playerid][pCarKey] == 0) { GameTextForPlayer(playerid, "~w~You do not have a car to locate", 2500, 3); return 1; }
if(cartrack[playerid]==0)
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Please enter your PIN # and password now");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Your vehicle's location is now uploaded to your phone");
SetPlayerCheckpoint(playerid,CarInfo[PlayerInfo[playerid][pCarKey]][cLocationx], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationy], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationz], 5.0);
cartrack[playerid] = 1;
return 1;
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: The tracking on your vehicle has been canceled");
DisablePlayerCheckpoint(playerid);
cartrack[playerid] = 0;
return 1;
}
}
if(strcmp(tmp, "lock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,1);
}
format(string, sizeof(string), "~w~Car~n~~r~Locked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 1;
return 1;
}
}
if(strcmp(tmp, "unlock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,0);
}
format(string, sizeof(string), "~w~Car~n~~g~Unlocked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 0;
return 1;
}
}
if(strcmp(tmp, "autolock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 0) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 1; format(string, sizeof(string), "~w~Car Autolock~n~~r~Engaged"); return 1; }
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 1) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 0; format(string, sizeof(string), "~w~Car Autolock~n~~g~Disengaged"); return 1; }
GameTextForPlayer(playerid, string, 10000, 3);
return 1;
}
}
return 0;
}
and all orders go but / v park goes
Help me please!
new vehid = GetPlayerVehicleID(playerid);
if(strcmp(cmd,"/v",true)==0)
{
// new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
format(string,sizeof(string),"________________%s__ ______________",CarInfo[CheckOwner(playerid)][cDescription]);
SendClientMessage(playerid, COLOR_GREEN,string);
SendClientMessage(playerid, COLOR_GRAD2,"** /v buy - Buys the car (if for sale)");
SendClientMessage(playerid, COLOR_GRAD2,"** /v sell - Sells the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v park - Park the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v exit - Exit the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v locate - Uses the car's On-Star to locate");
SendClientMessage(playerid, COLOR_GRAD2,"** /v lock - Locks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v unlock - Unlocks the car");
SendClientMessage(playerid, COLOR_GRAD2,"** /v autolock - Automatically locks the car upon exiting");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_GRAD2,"** You do not currently own a car! **");
return 1;
}
}
return 1;
}
if(strcmp(tmp,"exit",true)==0)
{
CarOffered[playerid]=0;
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
return 1;
}
if(strcmp(tmp, "buy", true) == 0)
{
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][ownedvehicle] == vehid)
{
if(PlayerInfo[playerid][pCarKey]!=0)
{
SendClientMessage(playerid, COLOR_GREY, "You already own a car, type /v sell if you want to buy this one!");
return 1;
}
if(CarInfo[i][cOwned]==1)
{
SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
return 1;
}
if(GetPlayerMoney(playerid) >= CarInfo[i][cValue])
{
PlayerInfo[playerid][pCarKey] = i;
CarInfo[i][cOwned] = 1;
CarOffered[playerid]=0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[i][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerMoney(playerid,-CarInfo[i][cValue]);
GameTextForPlayer(playerid, "~w~Congratulations~n~This is your car until you sell it!", 5000, 3);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /v(ehicles) to view the car manual!");
TogglePlayerControllable(playerid, 1);
SaveCars();
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have the cash for that!");
return 1;
}
}
}
}
return 1;
}
if(strcmp(tmp, "sell", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
return 1;
}
if(PlayerInfo[playerid][pCarKey] != 0 && strcmp(playername, CarInfo[PlayerInfo[playerid][pCarKey]][cOwner], true) == 0)
{
new car = PlayerInfo[playerid][pCarKey];
CarInfo[car][cOwned] = 0;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[car][cOwner], "Dealership", 0, strlen("Dealership"), 999);
GivePlayerMoney(playerid,CarInfo[car][cValue]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", CarInfo[car][cValue]);
GameTextForPlayer(playerid, string, 10000, 3);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
PlayerInfo[playerid][pCarKey] = 0;
return 1;
}
}
return 1;
}
if(strcmp(tmp,"park",true) == 0)
{
new Float,Float:y,Float:z;
new Float:a;
// new carid;
new getcarid;
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pCarKey]) { carid = PlayerInfo[playerid][pCarKey]; }
else { return 1; }
getcarid = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, playername, sizeof(playername));
GetVehiclePos(carid, x, y, z);
//GetPlayerFacingAngle(playerid, a);
GetVehicleZAngle(carid, a);
if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
{
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
return 1;
}
if(getcarid == carid)
{
CarInfo[carid][cLocationx] = x;
CarInfo[carid][cLocationy] = y;
CarInfo[carid][cLocationz] = z;
CarInfo[carid][cAngle] = a;
format(string, sizeof(string), "~n~ You have parked your vehicle in this location. ~n~");
GameTextForPlayer(playerid, "You have parked your vehicle in this position. It will respawn here.", 10000, 3);
DestroyVehicle(carid);
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
TogglePlayerControllable(playerid, 1);
return 1;
}
}
}
if(strcmp(tmp, "locate", true) == 0)
{
if(!IsPlayerConnected(playerid)) { return 1; }
if(PlayerInfo[playerid][pCarKey] == 0) { GameTextForPlayer(playerid, "~w~You do not have a car to locate", 2500, 3); return 1; }
if(cartrack[playerid]==0)
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Please enter your PIN # and password now");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: Your vehicle's location is now uploaded to your phone");
SetPlayerCheckpoint(playerid,CarInfo[PlayerInfo[playerid][pCarKey]][cLocationx], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationy], CarInfo[PlayerInfo[playerid][pCarKey]][cLocationz], 5.0);
cartrack[playerid] = 1;
return 1;
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"On-Star: This is On-Star's automated vehicle tracking system");
SendClientMessage(playerid,COLOR_WHITE,"On-Star: The tracking on your vehicle has been canceled");
DisablePlayerCheckpoint(playerid);
cartrack[playerid] = 0;
return 1;
}
}
if(strcmp(tmp, "lock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,1);
}
format(string, sizeof(string), "~w~Car~n~~r~Locked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 1;
return 1;
}
}
if(strcmp(tmp, "unlock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(IsPlayerConnected(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(CarInfo[keycar][ownedvehicle],i,0,0);
}
format(string, sizeof(string), "~w~Car~n~~g~Unlocked");
GameTextForPlayer(playerid, string, 10000, 3);
CarInfo[keycar][cLock] = 0;
return 1;
}
}
if(strcmp(tmp, "autolock", true) == 0)
{
new keycar = PlayerInfo[playerid][pCarKey];
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 0) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 1; format(string, sizeof(string), "~w~Car Autolock~n~~r~Engaged"); return 1; }
if(CarAutolock[CarInfo[keycar][ownedvehicle]] == 1) { CarAutolock[CarInfo[keycar][ownedvehicle]] = 0; format(string, sizeof(string), "~w~Car Autolock~n~~g~Disengaged"); return 1; }
GameTextForPlayer(playerid, string, 10000, 3);
return 1;
}
}
return 0;
}
and all orders go but / v park goes
Help me please!