Wanted Level 6 -
gotwarzone - 22.10.2013
How are you guys?
I just want to add this to my server. I want to give killer a score when he kills a player who has wanted level 6. You know just some bonus.
And sencliendtoall if someone hit the wanted level 6 like:
"Myname(ID) has a wanted level of 6 kill him to get score bonus"
Thanks and looking forward.
Re: Wanted Level 6 -
Threshold - 22.10.2013
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID && killerid != playerid)
{
if(GetPlayerWantedLevel(playerid) >= 6)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
GetPlayerName(playerid, dname, MAX_PLAYER_NAME);
GetPlayerName(killerid, kname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid);
//SetPlayerWantedLevel(playerid, 0);
}
}
return 1;
}
Re: Wanted Level 6 -
gotwarzone - 22.10.2013
Quote:
Originally Posted by BenzoAMG
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { if(killerid != INVALID_PLAYER_ID && killerid != playerid) { if(GetPlayerWantedLevel(playerid) >= 6) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME]; GetPlayerName(playerid, dname, MAX_PLAYER_NAME); GetPlayerName(killerid, kname, MAX_PLAYER_NAME); format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid); //SetPlayerWantedLevel(playerid, 0); } } return 1; }
|
Thanks my friend how about senclientmessagetoall?
I also want to notify to all players that "Playername has a wanted level of 6. Kill him to get score bonus"
Re: Wanted Level 6 -
Threshold - 22.10.2013
Well you'd have to set up a timer to do a check every so often, so lets say every 2 minutes.
pawn Код:
public OnGameModeInit() //Or OnFilterscriptInit for Filterscripts.
{
SetTimer("WantedCheck", 120000, true);
return 1;
}
forward WantedCheck();
public WantedCheck()
{
new fstr[150];
for(new i = 0; i < MAX_PLAYERS; i++) //foreach is a better option
{
if(IsPlayerConnected(i))
{
if(GetPlayerWantedLevel(i) >= 6)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(i, pname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has a wanted level of 6. Kill them to get a bonus score!", pname, i);
SendClientMessageToAll(0xFFFF00FF, fstr);
}
}
}
return 1;
}
Re: Wanted Level 6 -
gotwarzone - 22.10.2013
Quote:
Originally Posted by BenzoAMG
Well you'd have to set up a timer to do a check every so often, so lets say every 2 minutes.
pawn Код:
public OnGameModeInit() //Or OnFilterscriptInit for Filterscripts. { SetTimer("WantedCheck", 120000, true); return 1; }
forward WantedCheck(); public WantedCheck() { new fstr[150]; for(new i = 0; i < MAX_PLAYERS; i++) //foreach is a better option { if(IsPlayerConnected(i)) { if(GetPlayerWantedLevel(i) >= 6) { new pname[MAX_PLAYER_NAME]; GetPlayerName(i, pname, MAX_PLAYER_NAME); format(fstr, sizeof(fstr), "Player %s(%d) has a wanted level of 6. Kill them to get a bonus score!", pname, i); SendClientMessageToAll(0xFFFF00FF, fstr); } } } return 1; }
|
Is there any option without the timer? coz I used to much timer. I would also like to ask, does using timer too much cost lag or heavy server?
And please can you add this?
Код:
format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid);
So player will know who killed that guy who had wanted level 6.
Thanks alot. And sorry if I took your time.
Re: Wanted Level 6 -
Threshold - 22.10.2013
Oh crap lol, I forgot to add the SendClientMessageToAll xD
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID && killerid != playerid)
{
if(GetPlayerWantedLevel(playerid) >= 6)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
GetPlayerName(playerid, dname, MAX_PLAYER_NAME);
GetPlayerName(killerid, kname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid);
SendClientMessageToAll(0xFFFF00FF, fstr);
//SetPlayerWantedLevel(playerid, 0);
}
}
return 1;
}
A 2 minute timer will not really effect your server at all, multiple 1 second timers can cause issues though, but this shouldn't be a problem. Another alternative would be to run this every time a player gets a wanted level of 6, meaning you would have to make a custom function for your SetPlayerWantedLevel functions that would also do a check along with it, and then announcing it.
Re: Wanted Level 6 -
gotwarzone - 22.10.2013
Quote:
Originally Posted by BenzoAMG
Oh crap lol, I forgot to add the SendClientMessageToAll xD
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { if(killerid != INVALID_PLAYER_ID && killerid != playerid) { if(GetPlayerWantedLevel(playerid) >= 6) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME]; GetPlayerName(playerid, dname, MAX_PLAYER_NAME); GetPlayerName(killerid, kname, MAX_PLAYER_NAME); format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid); SendClientMessageToAll(0xFFFF00FF, fstr); //SetPlayerWantedLevel(playerid, 0); } } return 1; }
A 2 minute timer will not really effect your server at all, multiple 1 second timers can cause issues though, but this shouldn't be a problem. Another alternative would be to run this every time a player gets a wanted level of 6, meaning you would have to make a custom function for your SetPlayerWantedLevel functions that would also do a check along with it, and then announcing it.
|
Because before I also use this. But different before when a player(killer) when it exactly hits wanted level of 6, it automatically send to server but without any timer.
But for now maybe I can use with timer. As you said 2 minutes will not effect the server. so i'm happy to hear that. Thanks alot. And I ask too much I know you know that
D
EDIT:
Or you know I will use this?
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID && killerid != playerid)
{
if(GetPlayerWantedLevel(playerid) >= 6)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
GetPlayerName(playerid, dname, MAX_PLAYER_NAME);
GetPlayerName(killerid, kname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid);
//SetPlayerWantedLevel(playerid, 0);
}
}
return 1;
}
but I will change
Код:
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
new fstr[150], dname[MAX_PLAYER_NAME], kname[MAX_PLAYER_NAME];
GetPlayerName(playerid, dname, MAX_PLAYER_NAME);
GetPlayerName(killerid, kname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has killed %s(%d) with a wanted level of 6, and has claimed a bonus score!", kname, killerid, dname, playerid);
to
Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(i, pname, MAX_PLAYER_NAME);
format(fstr, sizeof(fstr), "Player %s(%d) has a wanted level of 6. Kill them to get a bonus score!", pname, i);
SendClientMessageToAll(0xFFFF00FF, fstr);
is it okay?