Event Help! - 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: Event Help! (
/showthread.php?tid=200512)
Event Help! -
Hamudi_Chi - 18.12.2010
Ok i got everything for a Event Script BUT when i try to /beginevent ( i have put in it to give weapon) but it is giving only the sender! help please I want to give everyone in the event weapons.
here is the script
Код:
public OnGameModeInit()
{
SetTimer("Event", 500, true);
return 1;
}
Код:
if(strcmp(cmd, "/beginevent", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
if(ActiveEvent == 1)
{
IsEventOn = 1;
if(IsAtEvent[playerid] == 1)
{
SendClientMessageToAll(COLOR_DBLUE, "The event has began!"); }
}
else
{
SendClientMessage(playerid, COLOR_GREY, " An event had already began!, use /endevent to finish the current event !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
}
}
return 1;
}
Код:
public Event(playerid)
{
if(ActiveEvent == 1)
{
if(IsEventOn == 1)
{
if(PlayerInfo[playerid][pEvent] == 1)
{
SetPlayerHealth(MAX_PLAYERS, EventHP);
SetPlayerArmour(MAX_PLAYERS, EventArmour);
ResetPlayerAdminWeaponsEx(MAX_PLAYERS);
ResetPlayerWeapons(MAX_PLAYERS);
GivePlayerAdminGun(MAX_PLAYERS, EventWeapon1);
GivePlayerAdminGun(MAX_PLAYERS, EventWeapon2);
GivePlayerAdminGun(MAX_PLAYERS, EventWeapon3);
GivePlayerAdminGun(MAX_PLAYERS, EventWeapon4);
GivePlayerAdminGun(MAX_PLAYERS, EventWeapon5);
}
}
}
}
Re: Event Help! -
Benjo - 18.12.2010
Working with what you have shown us, it looks like you just need to add a loop in the Event method to cycle through all the players:
pawn Код:
public Event(playerid) // I don't think you need the playerid parameter
{
if(ActiveEvent == 1)
{
if(IsEventOn == 1)
{
for(new i=0; i<MAX_PLAYERS; i++) // loops goes through all players
{
if(PlayerInfo[i][pEvent] == 1)
{
SetPlayerHealth(i, EventHP);
SetPlayerArmour(i, EventArmour);
ResetPlayerAdminWeaponsEx(i);
ResetPlayerWeapons(i);
GivePlayerAdminGun(i, EventWeapon1);
GivePlayerAdminGun(i, EventWeapon2);
GivePlayerAdminGun(i, EventWeapon3);
GivePlayerAdminGun(i, EventWeapon4);
GivePlayerAdminGun(i, EventWeapon5);
}
}
}
}
return 1;
}
Also, the timer you have set in OnGameModeInit will continually call this method ever 0.5 seconds; just something to bear in mind!