Help me! - 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: Help me! (
/showthread.php?tid=257718)
Help me! -
Cjgogo - 27.05.2011
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
Re: Help me! -
Cjgogo - 27.05.2011
anyone>?
Re: Help me! -
Cjgogo - 27.05.2011
nobody yet?
a few thoughts -
KoczkaHUN - 27.05.2011
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)
Anything more than 92 won't show on the client's screen, use 92.
Re: Help me! -
BigETI - 27.05.2011
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;
}
Re: Help me! -
Cjgogo - 28.05.2011
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