Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COORD_X 0000.0 // Define X
- #define COORD_Y 0000.0 // Define Y
- #define COORD_Z 0000.0 // Define Z
- /*
- Example
- 1024.768,1680.1050,2560.760
- X Y Z
- */
- forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
- /*
- Developers Notes:
- (C) Ravskie, 2009
- Don't remove the credits please.
- v1.0 (21/6/09)
- */
- enum pInfo
- {
- pCONNECTED_CHATROOM,
- pHAS_A_COMPUTER,
- pTALKING
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Ravskie's Computer Fitlerscript, v1.0");
- print("Loaded...");
- print("--------------------------------------\n");
- /* COMPUTER ACESS POINT */
- AddStaticPickup(1239, 23, COORD_X, COORD_Y, COORD_Z);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print("Ravskie's Computer Fitlerscript, v1.0");
- print("Exiting...");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
- PlayerInfo[playerid][pHAS_A_COMPUTER] = 1;
- PlayerInfo[playerid][pTALKING] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
- PlayerInfo[playerid][pHAS_A_COMPUTER] = 0;
- PlayerInfo[playerid][pTALKING] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new string[256];
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- if(PlayerInfo[playerid][pTALKING] == 1) {
- for(new i;i<MAX_PLAYERS;i++) {
- if(PlayerInfo[i][pCONNECTED_CHATROOM] == 1) {
- format(string, sizeof(string), "[CHATROOM - 1]: %s: %s", playername, text);
- SendClientMessage(i, COLOR_WHITE, string);
- }
- else if(PlayerInfo[i][pCONNECTED_CHATROOM] == 2) {
- format(string, sizeof(string), "[CHATROOM - 2]: %s: %s", playername, text);
- SendClientMessage(i, COLOR_WHITE, string);
- }
- else if(PlayerInfo[i][pCONNECTED_CHATROOM] == 3) {
- format(string, sizeof(string), "[CHATROOM - 3]: %s: %s", playername, text);
- SendClientMessage(i, COLOR_WHITE, string);
- }
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256];
- new string[256];
- new tmp[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- if (strcmp(cmd, "/disconnect", true)==0) {
- if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
- format(string, sizeof(string), "You don't own a computer.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- if(PlayerInfo[playerid][pCONNECTED_CHATROOM] == 0) {
- format(string, sizeof(string), "You are not connected to any chatroom.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- format(string, sizeof(string), "You have disconnected from the chatroom you we're in.");
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
- PlayerInfo[playerid][pTALKING] = 0;
- return 1;
- }
- if (strcmp(cmd, "/connect", true) == 0) {
- new itemid[16];
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) {
- SendClientMessage(playerid, COLOR_WHITE, "USAGE: /connect [room number]");
- SendClientMessage(playerid, COLOR_WHITE, "Room Numbers: 1, 2, 3");
- return 1;
- }
- strmid(itemid, tmp, 0, strlen(cmdtext), 255);
- new amount;
- tmp = strtok(cmdtext, idx);
- amount = strval(tmp);
- if(amount > 3 || amount < 1) {
- SendClientMessage(playerid, COLOR_WHITE, "Invalid amount [HINT: 1-3]");
- return 1;
- }
- if(strcmp(itemid, "1", true, strlen(itemid)) == 0) {
- if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
- if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
- format(string, sizeof(string), "You don't own a computer.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- format(string, sizeof(string), "You have connected to chatroom: 1.");
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 1;
- PlayerInfo[playerid][pTALKING] = 1;
- }
- }
- else if(strcmp(itemid, "2", true, strlen(itemid)) == 0) {
- if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
- if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
- format(string, sizeof(string), "You don't own a computer.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- format(string, sizeof(string), "You have connected to chatroom: 2.");
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 2;
- PlayerInfo[playerid][pTALKING] = 1;
- }
- }
- else if(strcmp(itemid, "3", true, strlen(itemid)) == 0) {
- if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
- if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
- format(string, sizeof(string), "You don't own a computer.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- return 1;
- }
- format(string, sizeof(string), "You have connected to chatroom: 3.");
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
- SendClientMessage(playerid, COLOR_WHITE, string);
- PlayerInfo[playerid][pCONNECTED_CHATROOM] = 3;
- PlayerInfo[playerid][pTALKING] = 1;
- }
- }
- return 1;
- }
- return 0;
- }
- strtok( const string[], &index, const seperator[] = " " )
- {
- new
- index2,
- result[ 30 ];
- index2 = strfind(string, seperator, false, index);
- if(index2 == -1) {
- if(strlen(string) > index) {
- strmid(result, string, index, strlen(string), 30);
- index = strlen(string);
- }
- return result;
- }
- if(index2 > (index + 29)) {
- index2 = index + 29;
- strmid(result, string, index, index2, 30);
- index = index2;
- return result;
- }
- strmid(result, string, index, index2, 30);
- index = index2 + 1;
- return result;
- }
- public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
- {
- if(IsPlayerConnected(playerid)) {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- tempposx = (oldposx -x);
- tempposy = (oldposy -y);
- tempposz = (oldposz -z);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
- return 1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement