Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #if defined FILTERSCRIPT
- #define PURPLE 0xB360FDFF //group colours
- stock groupexists(groupname[])
- {
- new gname[20];
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") != 0)
- {
- GetPVarString(i, "gname", gname,sizeof(gname));
- if(!strcmp(groupname,gname,true)) return 1;
- }
- }
- }
- return 0;
- }
- stock getgroupid(groupname[])
- {
- new gname[20], gid=0;
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") != 0)
- {
- GetPVarString(i,"gname",gname,sizeof(gname));
- if(!strcmp(groupname,gname,true)) return GetPVarInt(i,"groupid");
- if(strfind(gname,groupname) != -1) gid = GetPVarInt(i,"groupid");
- }
- }
- }
- return gid;
- }
- stock getgroupname(groupid)
- {
- new gname[20];
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") == groupid)
- {
- GetPVarString(i,"gname",gname,sizeof(gname));
- return gname;
- }
- }
- }
- return gname;
- }
- stock groupchat(playerid,text[])
- {
- new string[128], name[MAX_PLAYER_NAME];
- new gid = GetPVarInt(playerid,"groupid");
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"%s(%d): %s",name,playerid,text);
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(GetPVarInt(i,"groupid") == gid) SendClientMessage(i,PURPLE,string);
- if(GetPVarInt(i,"groupid") != gid && GetPVarInt(i,"level") != 0) SendClientMessage(i,PURPLE,string);
- }
- }
- stock groupmessage(gid,text[])
- {
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(GetPVarInt(i,"groupid") == gid) SendClientMessage(i,PURPLE,text);
- if(GetPVarInt(i,"groupid") != gid && GetPVarInt(i,"level") != 0) SendClientMessage(i,PURPLE,text);
- }
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(GetPVarInt(playerid,"groupid") != 0)
- {
- new gid=999, lid;
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") == GetPVarInt(playerid,"groupid") && i != playerid)
- {
- if(GetPVarInt(i,"groupjid") < gid)
- {
- gid = GetPVarInt(i,"groupjid");
- lid = i;
- }
- }
- }
- }
- DeletePVar(playerid,"gname");
- DeletePVar(playerid,"groupid");
- if(gid != 999)
- {
- new string[80];
- new name[MAX_PLAYER_NAME], gname[20];
- GetPlayerName(playerid,name,sizeof(name));
- GetPVarString(lid,"gname",gname,sizeof(gname));
- format(string,sizeof(string),"[%s] %s(%d) Has Left The Group",gname,name,playerid);
- groupmessage(GetPVarInt(lid,"groupid"),string);
- if(GetPVarInt(playerid,"groupjid") == 0)
- {
- GetPlayerName(lid,name,sizeof(name));
- format(string,sizeof(string),"[%s] %s(%d) Is The New Group Leader",gname,name,lid);
- groupmessage(GetPVarInt(lid,"groupid"),string);
- DeletePVar(lid,"groupjid");
- }
- }
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- CMD:groupcreate(playerid,params[])
- {
- if(GetPVarInt(playerid,"groupid") != 0) return SendClientMessage(playerid,RED,"You Need To Leave Your Current Group Before Creating A New One");
- new gid=1, gname[20],string[128];
- if(sscanf(params,"s[20]",gname)) return SendClientMessage(playerid,RED,"USAGE: /groupcreate [name]");
- if(!validtext(gname)) return SendClientMessage(playerid,RED,"Error Invalid Group Name");
- if(groupexists(gname)) return SendClientMessage(playerid,RED,"A Group Under That Name Already Exists");
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") != 0)
- {
- if(GetPVarInt(i,"groupid") == gid) gid++;
- }
- }
- }
- SetPVarInt(playerid,"groupjid",0);
- SetPVarString(playerid,"gname",gname);
- SetPVarInt(playerid,"groupid",gid);
- format(string,sizeof(string),"You Have Created The Group %s. Use /groupinvite [id] To Invite People",gname);
- return SendClientMessage(playerid,PURPLE,string);
- }
- CMD:groupleave(playerid,params[])
- {
- if(GetPVarInt(playerid,"groupid") == 0) return SendClientMessage(playerid,RED,"You Are Not In A Group");
- new gid=999, lid;
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") == GetPVarInt(playerid,"groupid") && i != playerid)
- {
- if(GetPVarInt(i,"groupjid") < gid)
- {
- gid = GetPVarInt(i,"groupjid");
- lid = i;
- }
- }
- }
- }
- DeletePVar(playerid,"gname");
- DeletePVar(playerid,"groupid");
- if(gid != 999)
- {
- new name[MAX_PLAYER_NAME], gname[20], string[128];
- GetPlayerName(playerid,name,sizeof(name));
- GetPVarString(lid,"gname",gname,sizeof(gname));
- format(string,sizeof(string),"[%s] %s(%d) Has Left The Group",gname,name,playerid);
- groupmessage(GetPVarInt(lid,"groupid"),string);
- if(GetPVarInt(playerid,"groupjid") == 0)
- {
- GetPlayerName(lid,name,sizeof(name));
- format(string,sizeof(string),"[%s] %s(%d) Is The New Group Leader",gname,name,lid);
- groupmessage(GetPVarInt(lid,"groupid"),string);
- DeletePVar(lid,"groupid");
- }
- }
- return SendClientMessage(playerid,PURPLE,"You Have Left Your Group");
- }
- CMD:groupjoin(playerid,params[])
- {
- if(GetPVarInt(playerid,"groupid") != 0) return SendClientMessage(playerid,RED,"You Are Already In A Group");
- new gid, gname[20], string[128];
- if(sscanf(params,"s[20]",gname)) return SendClientMessage(playerid,RED,"USAGE: /groupjoin [name]");
- if(!getgroupid(gname)) return SendClientMessage(playerid,RED,"Invalid Group Name");
- gid = getgroupid(gname);
- if(GetPVarInt(playerid,"groupinv") != gid)
- {
- for(new i=0;i<=MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"groupid") != 0 && GetPVarInt(i,"groupjid") == 0)
- {
- format(string,sizeof(string),"%s Has Asked To Join Your Group");
- SendClientMessage(i,PURPLE,string);
- SetPVarInt(playerid,"groupask",gid);
- }
- }
- }
- format(string,sizeof(string),"You Have Asked To Join The Group \"%s\"",getgroupname(gid));
- return SendClientMessage(playerid,PURPLE,string);
- }
- SetPVarInt(playerid,"groupid",gid);
- SetPVarString(playerid,"gname",getgroupname(gid));
- return 1;
- }
- CMD:groupinvite(playerid,params[])
- {
- if(GetPVarInt(playerid,"groupid") == 0) return SendClientMessage(playerid,RED,"You Are Not In A Group");
- if(GetPVarInt(playerid,"groupjid") != 0) return SendClientMessage(playerid,RED,"You Are Not Group Leader");
- new id, string[128], name[MAX_PLAYER_NAME];
- if(sscanf(params,"u",id)) return SendClientMessage(playerid,RED,"USAGE: /groupinvite [id]");
- if(!IsPlayerConnected(id))
- {
- new idx;
- format(string,sizeof(string),"%s",strtok(params, idx));
- format(string,sizeof(string),"Player %s Is Not Connected",string);
- return SendClientMessage(playerid,RED,string);
- }
- if(playerid == id) return SendClientMessage(playerid,RED,"You Cannot Invite Yourself");
- new gname[20];
- GetPVarString(playerid,"gname",gname,sizeof(gname));
- if(GetPVarInt(id,"groupask") != GetPVarInt(playerid,"groupid"))
- {
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"%s Has Invited You To Join Their Group \"%s\"",name,gname);
- SendClientMessage(id,PURPLE,string);
- SetPVarInt(id,"groupinv",GetPVarInt(playerid,"groupid"));
- GetPlayerName(id,name,sizeof(name));
- format(string,sizeof(string),"You Have Invited %s To Join Your Group",name);
- return SendClientMessage(playerid,PURPLE,string);
- }
- GetPlayerName(id,name,sizeof(name));
- format(string,sizeof(string),"%s Has Joined %s",name,gname);
- SetPVarInt(id,"groupid",GetPVarInt(playerid,"groupid"));
- SetPVarString(id,"gname",name);
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement