Help me!
#1

I had problems yesterday with this,and I'm kinda new to "loops" .A beta tester told me :"You should be using the loop to identify the ID of the driver of the ambulance and then storing that ID for later use. See usage of GetPlayerVehicleID and comparing it to vehicleid passed by the callback."

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;
}
I'm new to loops so please help,gvie me an example and pls don't give me just the wiki@loops
Reply
#2

anyone>?
Reply
#3

nobody yet?
Reply
#4

pawn Код:
new playerid2;
This gets never filled, it will be constantly ID 0
pawn Код:
if(GetPlayerState(playerid2) == PLAYER_STATE_DRIVER && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
You should also check the other player is in that vehicle.
pawn Код:
GivePlayerMoney(playerid,-500);
You should check if the player has the money.
pawn Код:
new medicname[24];
new healedname[24];
You don't have to use 24, use MAX_PLAYER_NAME instead (which is 20)
pawn Код:
new string[128];
Anything more than 92 won't show on the client's screen, use 92.
Reply
#5

Useless to make this system into OnPlayerEnterVehicle since this will be called when the player tries to enter the vehicle instead of being sucessfully a driver/passenger.
So we should make this system into OnPlayerStateChange


pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        new Float:health;
        GetPlayerHealth(playerid, health);
        if(health < 80.0)
        {
            for(new id = 0; id < MAX_PLAYERS; id++)
            {
                if(IsPlayerConnected(id) && gTeam[id] == TEAM_MEDICS && GetPlayerState(id) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(id) == GetPlayerVehicleID(playerid) && GetVehicleModel(GetPlayerVehicleID(id)) == 416)
                {
                    SetPlayerHealth(playerid, 100);
                    GivePlayerMoney(playerid, -500);
                    GivePlayerMoney(id, 500);
                    SetPlayerScore(id, GetPlayerScore(id)+2);
                    new medicname[MAX_PLAYER_NAME], healedname[MAX_PLAYER_NAME], string[128];
                    GetPlayerName(playerid, healedname, sizeof(healedname));
                    GetPlayerName(id, medicname, sizeof(medicname));
                    format(string, sizeof(string), "%s(%d) has been healed by medic %s(%d).", healedname, playerid, medicname, id);
                    SendClientMessageToAll(COLOR_GREY, string);
                    break;
                }
            }
        }
    }
    return 1;
}
Reply
#6

no compiling errors thanks to big now i think I understood the loops and thanks to Koczka I understood what I was doing wrong,thanks both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)