01.01.2013, 09:21
(
Последний раз редактировалось Pasketi; 07.01.2013 в 05:10.
Причина: another fix
)
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:
Edit: Checked and fixed the code:
The script is running on a server found from:
isgmc.no-ip.org:7777
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; }
Код:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
isgmc.no-ip.org:7777