23.07.2011, 22:13
guys it is possible to detect if the player is in watter or to remove some object of the map ? :/
stock IsPlayerInWater(playerid)
{
new animlib[32],tmp[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
if( !strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid) ) return true;
return false;
}
CMD:boat(playerid, cmdtext[])
{
if (!IsPlayerInWater(playerid)) return SendClientMessage(playerid, -1, "You have to be in water to use this command.");
new V, Float:pos[4];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
V = CreateVehicle(446, pos[0], pos[1], pos[2], pos[3], -1, -1, 1000);
PutPlayerInVehicle(playerid, V, 0);
SendClientMessage(playerid, -1, "Enjoy your boat mate! ;)");
return true;
}
stock IsPlayerInWater(playerid)
{
new animlib[32],tmp[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
if(!strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid)) return true;
return false;
}
public IsABoat(carid)
{
new modelid = GetVehicleModel(carid);
if(modelid == 430 || modelid == 446 || modelid == 452 || modelid == 453 || modelid == 454 || modelid == 472 || modelid == 473 || modelid == 484 || modelid == 493 || modelid == 595)
{
return 1;
}
return 0;
}
CMD:vehicle(playerid, params[])
{
new model;
new Float:pos[4];
new veh;
if(sscanf(params, "i", model)) {
SendClientMessage(playerid, -1, "Usage: /vehicle [model]");
} else {
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
if(IsPlayerInWater(playerid)) {
if(IsABoat(model)) {
SendClientMessage(playerid, -1, "Enjoy your vehicle.");
veh = CreateVehicle(model, pos[0], pos[1], pos[2], pos[3], -1, -1, 1000);
PutPlayerInVehicle(playerid, veh, 0);
} else SendClientMessage(playerid, -1, "You can only spawn boats in water.");
} else {
if(!IsABoat(model)) {
SendClientMessage(playerid, -1, "Enjoy your vehicle.");
veh = CreateVehicle(model, pos[0], pos[1], pos[2], pos[3], -1, -1, 1000);
PutPlayerInVehicle(playerid, veh, 0);
} else SendClientMessage(playerid, -1, "You can only spawn boats in water.");
}
}