05.11.2013, 13:21
Hi guys, I really want to create a /v command. So when you type /v it will say "[Usage]: /v [find, park, lock, get]". I have scripted the four commands and they work great I just need help with this part. I want to get all those commands so you can type /v find, or /v park, etc.
pawn Код:
CMD:get(playerid, params[])
{
new carid[24];
if(PlayerInfo[playerid][pVehicle1] == 0 && PlayerInfo[playerid][pVehicle2] == 0 && PlayerInfo[playerid][pVehicle3] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: You do not own a vehicle.");
if(sscanf(params, "s[24]", carid)) return SendClientMessage(playerid, COLOR_GREY, "[Usage]: /get [vehicleID]");
if(!strcmp(carid, "1", true))
{
if(PlayerInfo[playerid][pVehicle1] != 0)
{
if(PlayerInfo[playerid][pVehicle1Spawned] != 0)
{
new model1 = PlayerInfo[playerid][pVehicle1Model];
new Float:car1x = PlayerInfo[playerid][pVehicle1X];
new Float:car1y = PlayerInfo[playerid][pVehicle1Y];
new Float:car1z = PlayerInfo[playerid][pVehicle1Z];
new Float:car1c = PlayerInfo[playerid][pVehicle1C];
new car1color1 = PlayerInfo[playerid][pVehicle1Color1];
new car1color2 = PlayerInfo[playerid][pVehicle1Color2];
new Float:vehx, Float:vehy, Float:vehz; GetVehiclePos(personalcar1[playerid], vehx, vehy, vehz);
PlayerInfo[playerid][pVehicle1Lock] = 1;
PlayerInfo[playerid][pVehicle1Spawned] = 0;
personalcar1[playerid] = CreateVehicle(model1, car1x, car1y, car1z, car1c, car1color1, car1color2, 999999);
SetVehicleNumberPlate(personalcar1[playerid], PlayerInfo[playerid][pVehicle1Plate]);
GetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: This vehicle is already spawned.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 1.");
}
else if(!strcmp(carid, "2", true))
{
if(PlayerInfo[playerid][pVehicle2] != 0)
{
if(PlayerInfo[playerid][pVehicle2Spawned] != 0)
{
new model2 = PlayerInfo[playerid][pVehicle2Model];
new Float:car2x = PlayerInfo[playerid][pVehicle2X];
new Float:car2y = PlayerInfo[playerid][pVehicle2Y];
new Float:car2z = PlayerInfo[playerid][pVehicle2Z];
new Float:car2c = PlayerInfo[playerid][pVehicle2C];
new car2color1 = PlayerInfo[playerid][pVehicle2Color1];
new car2color2 = PlayerInfo[playerid][pVehicle2Color2];
SendClientMessage(playerid, COLOR_WHITE, "A checkpoint has been set to your vehicle in slot 2.");
PlayerInfo[playerid][pVehicle2Lock] = 1;
PlayerInfo[playerid][pVehicle2Spawned] = 0;
personalcar2[playerid] = CreateVehicle(model2, car2x, car2y, car2z, car2c, car2color1, car2color2, 999999);
SetVehicleNumberPlate(personalcar2[playerid], PlayerInfo[playerid][pVehicle2Plate]);
GetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: This vehicle is already spawned.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 2.");
}
else if(!strcmp(carid, "3", true))
{
if(PlayerInfo[playerid][pVehicle3] != 0)
{
if(PlayerInfo[playerid][pVehicle3Spawned] != 0)
{
new model3 = PlayerInfo[playerid][pVehicle3Model];
new Float:car3x = PlayerInfo[playerid][pVehicle3X];
new Float:car3y = PlayerInfo[playerid][pVehicle3Y];
new Float:car3z = PlayerInfo[playerid][pVehicle3Z];
new Float:car3c = PlayerInfo[playerid][pVehicle3C];
new car3color1 = PlayerInfo[playerid][pVehicle3Color1];
new car3color2 = PlayerInfo[playerid][pVehicle3Color2];
SendClientMessage(playerid, COLOR_WHITE, "A checkpoint has been set to your vehicle in slot 3.");
PlayerInfo[playerid][pVehicle3Lock] = 1;
PlayerInfo[playerid][pVehicle3Spawned] = 0;
personalcar3[playerid] = CreateVehicle(model3, car3x, car3y, car3z, car3c, car3color1, car3color2, 999999);
SetVehicleNumberPlate(personalcar3[playerid], PlayerInfo[playerid][pVehicle3Plate]);
GetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: This vehicle is already spawned.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 3.");
}
return 1;
}
CMD:find(playerid, params[])
{
new carid[24];
if(PlayerInfo[playerid][pVehicle1] == 0 && PlayerInfo[playerid][pVehicle2] == 0 && PlayerInfo[playerid][pVehicle3] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: You do not own a vehicle.");
if(sscanf(params, "s[24]", carid)) return SendClientMessage(playerid, COLOR_GREY, "[Usage]: /find [vehicleID]");
if(!strcmp(carid, "1", true))
{
if(PlayerInfo[playerid][pVehicle1] != 0)
{
CP[playerid] = 69;
new Float:vehx, Float:vehy, Float:vehz; GetVehiclePos(personalcar1[playerid], vehx, vehy, vehz);
SetPlayerCheckpoint(playerid, vehx, vehy, vehz, 6.0);
SendClientMessage(playerid, COLOR_WHITE, "A checkpoint has been set to your vehicle in slot 1.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 1.");
}
else if(!strcmp(carid, "2", true))
{
if(PlayerInfo[playerid][pVehicle2] != 0)
{
CP[playerid] = 69;
new Float:vehx, Float:vehy, Float:vehz; GetVehiclePos(personalcar2[playerid], vehx, vehy, vehz);
SetPlayerCheckpoint(playerid, vehx, vehy, vehz, 6.0);
SendClientMessage(playerid, COLOR_WHITE, "A checkpoint has been set to your vehicle in slot 2.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 2.");
}
else if(!strcmp(carid, "3", true))
{
if(PlayerInfo[playerid][pVehicle3] != 0)
{
CP[playerid] = 69;
new Float:vehx, Float:vehy, Float:vehz; GetVehiclePos(personalcar3[playerid], vehx, vehy, vehz);
SetPlayerCheckpoint(playerid, vehx, vehy, vehz, 6.0);
SendClientMessage(playerid, COLOR_WHITE, "A checkpoint has been set to your vehicle in slot 3.");
}
else return SCM(playerid, COLOR_LIGHTRED, "[Error]: You do not have a vehicle in slot 3.");
}
return 1;
}
CMD:park(playerid, params[])
{
if(PlayerInfo[playerid][pVehicle1] == 0 && PlayerInfo[playerid][pVehicle2] == 0 && PlayerInfo[playerid][pVehicle3] == 0)
return SendClientMessage(playerid, COLOR_WHITE, "You do not own any vehicles to park.");
new vehid, vehid2, vehid3;
if(GetPlayerVehicleID(playerid) == personalcar1[playerid]) { vehid = personalcar1[playerid]; }
else if(GetPlayerVehicleID(playerid) == personalcar2[playerid]) { vehid2 = personalcar2[playerid]; }
else if(GetPlayerVehicleID(playerid) == personalcar3[playerid]) { vehid3 = personalcar3[playerid]; }
else return SendClientMessage(playerid, COLOR_WHITE, "You need to be in your vehicle to perform this action.");
if(IsPlayerInVehicle(playerid, vehid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:x,Float:y,Float:z,Float:a;
GetVehiclePos(vehid, x, y, z);
GetVehicleZAngle(vehid, a);
PlayerInfo[playerid][pVehicle1X] = x;
PlayerInfo[playerid][pVehicle1Y] = y;
PlayerInfo[playerid][pVehicle1Z] = z;
PlayerInfo[playerid][pVehicle1C] = a;
OnPlayerUpdate(playerid);
DestroyVehicle(personalcar1[playerid]);
PlayerInfo[playerid][pVehicle1Spawned] = 1;
return 1;
}
else if(IsPlayerInVehicle(playerid, vehid2) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:x,Float:y,Float:z,Float:a;
GetVehiclePos(vehid2, x, y, z);
GetVehicleZAngle(vehid2, a);
PlayerInfo[playerid][pVehicle2X] = x;
PlayerInfo[playerid][pVehicle2Y] = y;
PlayerInfo[playerid][pVehicle2Z] = z;
PlayerInfo[playerid][pVehicle2C] = a;
OnPlayerUpdate(playerid);
DestroyVehicle(personalcar2[playerid]);
PlayerInfo[playerid][pVehicle2Spawned] = 1;
return 1;
}
else if(IsPlayerInVehicle(playerid, vehid3) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:x,Float:y,Float:z,Float:a;
GetVehiclePos(vehid3, x, y, z);
GetVehicleZAngle(vehid3, a);
PlayerInfo[playerid][pVehicle3X] = x;
PlayerInfo[playerid][pVehicle3Y] = y;
PlayerInfo[playerid][pVehicle3Z] = z;
PlayerInfo[playerid][pVehicle3C] = a;
OnPlayerUpdate(playerid);
DestroyVehicle(personalcar3[playerid]);
PlayerInfo[playerid][pVehicle3Spawned] = 1;
return 1;
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: You need to be in your vehicle to perform this action.");
}
CMD:lock(playerid, params[])
{
new
Float:X1,Float:Y1,Float:Z1, Float:X2,Float:Y2,Float:Z2, Float:X3,Float:Y3,Float:Z3;
GetVehiclePos(personalcar1[playerid],X1,Y1,Z1);
GetVehiclePos(personalcar2[playerid],X2,Y2,Z2);
GetVehiclePos(personalcar3[playerid],X3,Y3,Z3);
if(PlayerInfo[playerid][pVehicle1] == 0 && PlayerInfo[playerid][pVehicle2] == 0 && PlayerInfo[playerid][pVehicle3] == 0)
return SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: You do not own a vehicle.");
if(IsPlayerInRangeOfPoint(playerid, 5.0, X1, Y1, Z1))
{
if(PlayerInfo[playerid][pVehicle1] != 0)
{
if(PlayerInfo[playerid][pVehicle1Lock] == 0)
{
GetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle1Lock] = 1;
GameTextForPlayer(playerid, "~w~vehicle ~r~ LOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
else if(PlayerInfo[playerid][pVehicle1Lock] == 1)
{
GetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, 0, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle1Lock] = 0;
GameTextForPlayer(playerid, "~w~vehicle ~g~ UNLOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
}
}
else if(IsPlayerInRangeOfPoint(playerid, 5.0, X2, Y2, Z2))
{
if(PlayerInfo[playerid][pVehicle2] != 0)
{
if(PlayerInfo[playerid][pVehicle2Lock] == 0)
{
GetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle2Lock] = 1;
GameTextForPlayer(playerid, "~w~vehicle ~r~ LOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
else if(PlayerInfo[playerid][pVehicle2Lock] == 1)
{
GetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, 0, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle2Lock] = 0;
GameTextForPlayer(playerid, "~w~vehicle ~g~ UNLOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
}
}
else if(IsPlayerInRangeOfPoint(playerid, 5.0, X3, Y3, Z3))
{
if(PlayerInfo[playerid][pVehicle3] != 0)
{
if(PlayerInfo[playerid][pVehicle3Lock] == 0)
{
GetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle3Lock] = 1;
GameTextForPlayer(playerid, "~w~vehicle ~r~ LOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
else if(PlayerInfo[playerid][pVehicle3Lock] == 1)
{
GetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, 0, bonnet, boot, objective);
PlayerInfo[playerid][pVehicle3Lock] = 0;
GameTextForPlayer(playerid, "~w~vehicle ~g~ UNLOCKED", 3000, 6);
OnPlayerUpdate(playerid);
}
}
}
return 1;
}