06.12.2013, 15:49
Hello everyone,
I've been facing a problem, As scripted that the regular players can't spawn hydra. If they type /v hydra it returns an error, but when they type /v 520, they can spawn it?
So how can i prevent them from spawning it Using the ID aswell?
Here's the code
The indentations are a bit fugged up, so please don't mind :P
-Signed
SsHady!
I've been facing a problem, As scripted that the regular players can't spawn hydra. If they type /v hydra it returns an error, but when they type /v 520, they can spawn it?
So how can i prevent them from spawning it Using the ID aswell?
Here's the code
pawn Код:
CMD:v(playerid, params[])
{
new Vehicle[32], VehicleID;
PlayerInfo[playerid][pCanSpawnVehicle] = true;
if(sscanf(params, "s[32]", Vehicle))
{
PlayerInfo[playerid][pCanSpawnVehicle] = true;
SendClientMessage(playerid, COLOR_GREEN, "{00FF00}USAGE: {C0C0C0}/v [vehicle name/id] [color 1 (optional)] [color 2 (optional)]");
SendClientMessage(playerid, COLOR_GREEN, "Example: /v infernus, /v inf or /v 411");
return 1;
}
if(PlayerInfo[playerid][pCanSpawnVehicle])
{
VehicleID = GetVehicleModelIDFromName(Vehicle);
if(VehicleID != 425 && VehicleID != 520 && VehicleID != 432 && VehicleID != 447 && VehicleID != 464 && VehicleID != 469) {
if(VehicleID == -1 )
{
VehicleID = strval(Vehicle);
if(VehicleID < 400 || VehicleID > 611 )
{
return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehicle name/id.");
}
}
GetPlayerPos(playerid, pX, pY, pZ);
GetPlayerFacingAngle(playerid, pAngle);
DestroyVehicle(PlayerInfo[playerid][pSpawnVehicle]);
PlayerInfo[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, -1, -1, -1);
LinkVehicleToInterior(PlayerInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, PlayerInfo[playerid][pSpawnVehicle], 0);
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
format(string, sizeof(string),"* You successfully spawned the vehicle %s.",vNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessage(playerid,COLOR_GREEN,string);
} else {
SendClientMessage(playerid, COLOR_GREY, "You are not allowed to spawn this vehicle.");
}
} else {
SendClientMessage(playerid, COLOR_GREY, "You cannot spawn vehicles in this zone.");
}
return 1;
}
-Signed
SsHady!