SA-MP Forums Archive
it is possible - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: it is possible (/showthread.php?tid=271314)



it is possible - Rafa - 23.07.2011

guys it is possible to detect if the player is in watter or to remove some object of the map ? :/


Re: it is possible - Fj0rtizFredde - 23.07.2011

Yes it is possible to detect if a player is in the water. And you can't remove orginal objects from the map.


Re: it is possible - iPLEOMAX - 23.07.2011

Meh, I found this in Useful functions when I did a search:

pawn Код:
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;
}



Re: it is possible - Rafa - 23.07.2011

i want to make if the player is not in water to cant spawn a boat and if he is in watter he can spawn boat but not cars how i can do that ?


Re: it is possible - iPLEOMAX - 23.07.2011

pawn Код:
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;
}
Untested, but it should work.


Re: it is possible - Rafa - 23.07.2011

dude i think dont have code IsPlayerInWater if have i will maked


Re: it is possible - iPLEOMAX - 23.07.2011

Quote:
Originally Posted by Rafa
Посмотреть сообщение
dude i think dont have code IsPlayerInWater if have i will maked
lol, look up, I gave you the code (IsPlayerInWater) already.


Re: it is possible - jameskmonger - 23.07.2011

pawn Код:
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.");
              }
}



Re: it is possible - Rafa - 23.07.2011

lol oh thanks mate now ill test xD


Re: it is possible - jameskmonger - 23.07.2011

My version is a lot more detailed than iPLEOMAX's, go ingame and type /vehicle