Help me!
#1

Ok so by the script you'll realise that what I'm trying to make is that if an injuried person enters an ambulance and in the ambulance is a medic as a driver,the injuried player gets healed:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new p2;
    if(GetPlayerState(p2) == PLAYER_STATE_DRIVER && IsPassenger(playerid))
    {
       if(gTeam[p2] == TEAM_MEDICS)
       {
        new Floath:health;
        if(GetPlayerHealth(playerid,health) < 80) //456
        {
          if(vehicleid == 416)
          {
           new string[128];
           new medicname[24];
           new healedname[24];
           GetPlayerName(p2,sizeof(p2),medicname); //463
           GetPlayerName(playerid,sizeof(playerid),healedname); //464
           format(string,sizeof(string),"%s has been healed by medic %s",healedname,medicname);
           SendClientMessageToAll(COLOR_GREY,string);
           GivePlayerMoney(playerid,-500);
           GivePlayerMoney(p2,500);
           SetPlayerScore(p2,GetPlayerScore(p2) + 2);
          }
       }
     }
    }
    return 1;
}
Errors:

Код:
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R2-2_win32\gamemodes\sfcrdmrp.pwn(451) : error 017: undefined symbol "IsPassenger"
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R2-2_win32\gamemodes\sfcrdmrp.pwn(456) : warning 213: tag mismatch
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R2-2_win32\gamemodes\sfcrdmrp.pwn(463) : error 035: argument type mismatch (argument 2)
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R2-2_win32\gamemodes\sfcrdmrp.pwn(464) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#2

You're missing a function for IsPassenger(playerid)?

Or are you simply trying to use the ispassenger parameter that is passed by the callback? If so then simply change IsPassenger(playerid) to ispassenger.

Also why are you making a variable that defaults to 0 and then getting the state of playerid 0 and check if it's the driver state? Not sure what you hope to achieve there
Reply
#3

https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle

The function IsPassenger just checks if a player goes into a vehicle as passenger or not..

What you need is
pawn Код:
PLAYER_STATE_PASSENGER
Reply
#4

ok and for health?what's worng there?
Reply
#5

GetPlayerHealth doesn't return the value of the players health, it stores it in a float. Therefore you have to compare the float and not the return value of the function. For example:

pawn Код:
new Floath:health;
GetPlayerHealth(playerid,health);
if(health < 80)
{
Please make sure you are using the SA-MP Wiki for information about the functions and callbacks.

https://sampwiki.blast.hk/wiki/GetPlayerHealth
Reply
#6

ok now is working perfect but the problem is i can't test it on my server for moment,so tell me please do you think this would work properly:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new playerid2;
    if(gTeam[playerid2] == TEAM_MEDICS)
    {
      if(GetPlayerState(playerid2) == PLAYER_STATE_DRIVER && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
      {
        GetVehicleModel(vehicleid);
        if(vehicleid == 416)
        {
          new Float:health;
          GetPlayerHealth(playerid,health);
          if(health < 80)
          {
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-500);
            GivePlayerMoney(playerid2,500);
            SetPlayerScore(playerid2,GetPlayerScore(playerid2) + 2);
            new medicname[24];
            new healedname[24];
            new string[128];
            GetPlayerName(playerid,healedname,sizeof(healedname));
            GetPlayerName(playerid2,medicname,sizeof(medicname));
            format(string,sizeof(string),"%s has been healed by medic %s.",healedname,medicname);
            SendClientMessageToAll(COLOR_GREY,string);
        }
       }
     }
    }
    return 1;
}
Reply
#7

There is still flawed logic here, I don't understand what you're trying to achieve by having a variable that never changes which contains 0 and calling it playerid2? What is that going to achieve? It will just mean that everytime this piece of code is run, playerid 0 will always get 500 dollars and be announced in chat as a medic, which doesn't make much sense unless ID 0 is always a medic in your server?

All of the code is actually doing this:

pawn Код:
if(gTeam[0] == TEAM_MEDICS)
    {
      if(GetPlayerState(0) == PLAYER_STATE_DRIVER && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
      {
// And so on
So what's the point of the variable at all?
Reply
#8

I understand ok then wait I'll release the code again and please tell me if that gonna work

I guess I have to do somethign with:

for(new i=0;i<MAX_PLAYERS;i++)
right?
Reply
#9

Don't double post, and yes it would appear that if you're trying to find the driver of the ambulance, you will need to use a loop to find out who is driving it.
Reply
#10

I guess this is also worng(sorry until now evrything I have done was commands for 2 players wich is easy but something that doesnt inlcudes command I haven't done yet):

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    new playerid2 = i;
    if(gTeam[playerid2] == TEAM_MEDICS)
    {
      if(GetPlayerState(playerid2) == PLAYER_STATE_DRIVER && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
      {
        GetVehicleModel(vehicleid);
        if(vehicleid == 416)
        {
          new Float:health;
          GetPlayerHealth(playerid,health);
          if(health < 80)
          {
            SetPlayerHealth(playerid,100);
            GivePlayerMoney(playerid,-500);
            GivePlayerMoney(playerid2,500);
            SetPlayerScore(playerid2,GetPlayerScore(playerid2) + 2);
            new medicname[24];
            new healedname[24];
            new string[128];
            GetPlayerName(playerid,healedname,sizeof(healedname));
            GetPlayerName(playerid2,medicname,sizeof(medicname));
            format(string,sizeof(string),"%s has been healed by medic %s.",healedname,medicname);
            SendClientMessageToAll(COLOR_GREY,string);
        }
       }
     }
    }
   }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)