Could you check this little FS for me? -
Pasketi - 01.01.2013
Hi! I decided to create a small filterscript on my server. It's my first script, that should create a small minigame of Cops and Robbers on a Grand Larceny -server. I have not yet tested it, I just wrote it :3
Here's what it should do:
If there are no robbers on the server, someone should type /robber to become the robber.
Otherwise everyone is a "Cop".
When someone types /robber, he respawns, loses all his money and gets a wanted level of 6.
If robber dies by his own hand, the game resets and everyone is a "Cop" again.
If a "Cop" kills the Robber, that specific cop becomes the Robber (he respawns etc.)
If a Robber kills a "Cop", he gains 5000$ for doing so.
If a "Cop" teamkills other "Cop", nothing happens.
If the robber disconnects, the game resets.
A "Cop" is more like a bounty hunter, that goes Rogue after killing.
Aaaaaand the code:
Код:
#define FILTERSCRIPT
#include <a_samp>
#define Criminal 1
#define Cop NO_TEAM
new robberid;
new robber = 1;
new pname[MAX_PLAYER_NAME+1], kname[MAX_PLAYER_NAME+1];
#if defined filterscript
public OnFilterScriptInIt()
{
print("\n--------------------------------------");
print(" Cops and Robber(s) by »iSG« Pasketi ");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Cops and Robber(s) by »iSG« Pasketi");
print("----------------------------------\n");
}
#endif
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0xFFFFFFFF, "There can be only one robber. Type /robber to find out, who is the robber.");
SetPlayerTeam(playerid, Cop);
printf("%s Connected",pname);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
printf("%s disconnected",pname);
GetPlayerName(playerid, pname, sizeof(pname));
if(GetPlayerTeam(playerid) == Criminal)
{
robber = 1;
new string[200];
format(string, sizeof(string), "%s disconnected. First player to type %srobber will be the robber.",pname,"/");
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent lags
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
GetPlayerName(playerid, pname, sizeof(pname));
if(GetPlayerTeam(playerid) == Criminal)
{
robberid = playerid;
new string[200];
format(string,sizeof(string),"A robber called %s has spawned!",pname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent laggs
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
SetPlayerWantedLevel(playerid, 6);
ResetPlayerMoney(playerid);
}
else
{
SetPlayerTeam(playerid, Cop);
GivePlayerMoney(playerid, 100000);
SetPlayerWantedLevel(playerid, 0);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new string[200];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(killerid, kname, sizeof(kname));
printf("%s killed %s",kname,pname);
if(GetPlayerTeam(playerid) == Criminal && GetPlayerTeam(killerid) == Cop)
{
printf("Cop -> Robber %s - team %i",pname,GetPlayerTeam(playerid));
SetPlayerTeam(playerid, Cop);
SetPlayerTeam(killerid, Criminal);
SpawnPlayer(killerid);
format(string, sizeof(string), "%s was killed by %s.", pname, kname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent laggs
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
else if(GetPlayerTeam(playerid) == Cop && GetPlayerTeam(killerid) == Cop)
{
printf("Cop teamkill %s - team %i",pname,GetPlayerTeam(playerid));
format(string, sizeof(string), "%s was teamkilled by %s.", pname, kname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent laggs
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
else if(GetPlayerTeam(playerid) == Criminal && killerid == INVALID_PLAYER_ID)
{
printf("Robber suicide %s - team %i",pname,GetPlayerTeam(playerid));
robber = 1;
SetPlayerTeam(playerid, Cop);
format(string, sizeof(string), "%s killed himself. First player to type /robber will be the robber.", pname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent lags
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
else if(GetPlayerTeam(playerid) == Cop && killerid == INVALID_PLAYER_ID)
{
printf("Cop suicide %s - team %i", pname, GetPlayerTeam(playerid));
format(string, sizeof(string), "%s killed himself.", pname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent lags
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
else
{
printf("Robber -> Cop %s - team %i",pname,GetPlayerTeam(playerid));
GivePlayerMoney(killerid, 5000);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
GetPlayerName(playerid, pname, sizeof(pname));
if (strcmp("/robber", cmdtext, true, 10) == 0)
{
if(robber == 1)
{
robber = 0;
SpawnPlayer(playerid);
SetPlayerTeam(playerid, Criminal);
SetPlayerWantedLevel(playerid, 6);
new string[128];
format(string, sizeof(string), "%s is the new robber. Get him!", pname);
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players (just a '500' loop)
{
if(IsPlayerConnected(i)) //If the player is connected, prevent laggs
{
SendClientMessage(i, 0xFFFFFFFF, string);
}
}
}
else
{
new string[128];
GetPlayerName(robberid, pname, sizeof(pname));
format(string, sizeof(string), "%s is the robber. Get him!", pname);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
return 1;
}
return 0;
}
Edit: Checked and fixed the code:
Код:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
The script is running on a server found from:
isgmc.no-ip.org:7777
Re: Could you check this little FS for me? -
hydravink - 01.01.2013
Why don't you test it yourself?
Re: Could you check this little FS for me? -
NicholasA - 01.01.2013
Quote:
Originally Posted by hydravink
Why don't you test it yourself?
|
Exactly
Re: Could you check this little FS for me? -
Gamer_007 - 01.01.2013
LOL wht problem u have testing urself.
Re: Could you check this little FS for me? -
Pasketi - 01.01.2013
well... The fact that I wrote that on a mac, but since this forum is so rude, I eventually took a teamviewer -connection 50km away, and got it working. I just wanted someone to check the code for errors. That's why.
Now I gotta find a way to disable Grand Larceny's TP-system... I'd appreciate help -.-
EDIT: nvm, found it. I'd need some more playtesting, though... I don't have enough people to do any kind of stress tests (I have tested this a bit, but not too much)
Problem now is that the "Cops" don't damage each other, even though on team 255.
Re: Could you check this little FS for me? -
Pasketi - 01.01.2013
Bump for play test help :3
and Gamer_007, you could be a little more appropriate, helpful and write a little cleaner english. My blood boils right now.