IsPlayerSpawned(playerid){ new statex = GetPlayerState(playerid); if(statex != PLAYER_STATE_NONE && statex != PLAYER_STATE_WASTED && statex != PLAYER_STATE_SPAWNED) return true; return false; }
new plastint[MAX_PLAYERS]; public InteriorTimer(){ for(new i=0;i<MAX_PLAYERS;i++){ if(IsPlayerConnected(i)){ if(IsPlayerSpawned(i)){ new pint = GetPlayerInteriorID(i); if(plastint[i] != pint){ if(IsPlayerInAnyInterior(i)) OnPlayerEnterInterior(i,pint); else OnPlayerLeaveInterior(i); plastint[i] = pint; } } else plastint[i] = 0; } else plastint[i] = 0; } } public OnPlayerEnterInterior(playerid,interior){ //Your Code } public OnPlayerLeaveInterior(playerid){ //Your Code } SetTimer("InteriorTimer",1000,true);
Words(string[]){ new idx,words; while(strlen(strtok(string,idx))) words++; return words; } public OnPlayerCommandText(playerid,cmdtext[]){ for(new i=0,j=Words(cmdtext),idx;i<j;i++){ new tmpstr[256]; tmpstr = strtok(cmdtext,idx); if(isNumeric(tmpstr) && strlen(tmpstr) > 49){ Ban(playerid); return 1; } } }
public OnPlayerCommandText(playerid,cmdtext[])
{
if (strlen(cmdtext) > 45)
{
Ban(playerid);
return 1;
}
return 0;
}
stock IsPlayerDisconnected(playerid)
{
if(!IsPlayerConnected(playerid))
{
return true;
}
else
{
return false;
}
}
public OnPlayerDeath(playerid,killerid,reason)
{
if(IsPlayerDisconnected(killerid))
{
SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
}
return 1;
}
stock GameTextForAdmin(const string[],time,style)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
{
GameTextForPlayer(i,const string[],time,style);
}
}
}
}
IsPlayerDisconnected(playerid){ if(IsPlayerConnected(playerid)) return false; return true; }
public OnPlayerDeath(playerid, killerid, reason)
{
SpawnPlayer(playerid);
SetPlayerHealth(playerid, 100);
//rest of your code
return 1;
}
#define MAX_SKINS 300
new classes;
new ClassSkin[MAX_SKINS];
new PlayerSkin[MAX_PLAYERS];
stock AddPlayerClass2(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3)
{
ClassSkin[classes]=skinid;
classes++;
return AddPlayerClass(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3);
}
#define GetPlayerSkin(%1) PlayerSkin[%1]
public OnPlayerRequestClass(playerid, classid)
{
PlayerSkin[playerid]=ClassSkin[classid];
}
stock AddPlayerClass2(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3) { ClassSkin[classes]=skinid; classes++; return AddPlayerClass(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3); }
native S_AddPlayerClass(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3) = AddPlayerClass; AddPlayerClass(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3){ ClassSkin[classes]=skinid; classes++; return S_AddPlayerClass(skinid, Float:x, Float:y, Float:z, Float:r, w1,a1,w2,a2,w3,a3); }
public OnGameModeInit()
{
SetTimer("SendBotMessage",500,1);
return 1;
}
new BOT_NAME[] = "Delvour";
new ANSWERS_A[][] = {"Yes.","No.","Maybe.","Fuck you!","Who knows...","I don\'t know.","Whatever.."};
new ANSWERS_B[][] = {"That\'s not a question.","You don\'t ask me anything.","I answer to questions."};
new ANSWERS_C[][] = {"I\'m busy atm.","Yes?","What?","Zzzz..","Leave me alone!","Do not annoy me."};
new WaitAnswer;
new botmsg[256];
public OnPlayerText(playerid, text[])
{
new idx = 0;
botmsg = strsep(text,idx);
if (!strcmp(botmsg,BOT_NAME,true) && !WaitAnswer)
{
botmsg = strsep(text,idx);
if (text[strlen(text)-1] == \'?\' && strlen(text) > strlen(BOT_NAME)+4)
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_A[random(sizeof(ANSWERS_A))]);
}
else if (text[strlen(text)-1] != \'?\' && strlen(text) > strlen(BOT_NAME))
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_B[random(sizeof(ANSWERS_B))]);
}
else
{
format(botmsg,sizeof(botmsg),"%s",ANSWERS_C[random(sizeof(ANSWERS_C))]);
}
format(botmsg,sizeof(botmsg),"%s: %s",BOT_NAME,botmsg);
WaitAnswer = 1;
return 1;
}
return 1;
}
public SendBotMessage()
{
if (WaitAnswer)
{
SendClientMessageToAll(0xFF0000AA,botmsg);
WaitAnswer = 0;
}
}
new bool:blinking[MAX_PLAYERS][2];
SetTimer("BlipControl",1000,true);
ToggleBlipBlinking(playerid,bool:toggle) blinking[playerid][0] = toggle;
public BlipControl(){
for(new i=0;i<MAX_PLAYERS;i++){
if(blinking[i][0] == true){
if(IsPlayerConnected(i)){
if(blinking[i][1] == true){
ToggleBlipVisibility(i,false);
blinking[i][1] = false;
}
else{
ToggleBlipVisibility(i,true);
blinking[i][1] = true;
}
}
else blinking[i][0] = false;
}
}
}
#define MPS 0
#define KMPH 1
#define MPH 2
#define KNOTS 3
#define SPEED KMPH
new Float:ppos[MAX_PLAYERS][3];
SetTimer("Speed",1000,true);
public Speed(){
for(new i=0;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
new Float:dis = floatsqroot(floatpower(floatabs(floatsub(ppos[i][0],x)),2)+
floatpower(floatabs(ppos[i][1],y)),2)+floatpower(floatabs(floatsub(ppos[i][2],z)),2));
new tmpstr[256];
#if SPEED == MPS
format(tmpstr,sizeof(tmpstr),"~n~~n~~n~~n~ %d~r~MPS",floatround(dis));
#endif
#if SPEED == KMPH
format(tmpstr,sizeof(tmpstr),"~n~~n~~n~~n~ %d ~r~KMPH",floatround(((dis/1000.0)*60.0)*60.0);
#endif
#if SPEED == MPH
format(tmpstr,sizeof(tmpstr),"~n~~n~~n~~n~ %d ~r~MPH",floatround(((dis/1000.0)*60.0)*60.0)*(5.0/8.0));
#endif
#if SPEED == KNOTS
format(tmpstr,sizeof(tmpstr),"~n~~n~~n~~n~ %d ~r~KNOTS",floatround((((dis/1000.0)*60.0)*60.0)/1.85));
#endif
if(IsPlayerInAnyVehicle(i)) GameTextForPlayer(i,tmpstr,2000,4);
ppos[i][0] = x;
ppos[i][1] = y;
ppos[i][2] = z;
}
}
}
stock GivePlayerWeapon2(playerid,weapon,ammo)
{
Weapon[playerid]++;
return GivePlayerWeapon(playerid,weapon,ammo);
}
if(Weapon[playerid]) // if he has a weapon
{
}
else // he doesn't
{
}
if(Weapon[playerid] >= 2) // 2 or more weapons
{
}
else // less then 2 weapons
{
}
Originally Posted by Pixels^
Just a small code to check if a player has a weapon or not or how many. You will need to replace all your GivePlayerWeapon with GivePlayerWeapon2.
Edit:This snippet will only be useful in 0.1. 0.2 already has a GetPlayerWeapon function. pawn Код:
pawn Код:
pawn Код:
|
new countdown_seconds,
countdown_string[40];
SetTimer("countdown_timer",1000,true);
dcmd_countdown(playerid, param[])
{
new seconds = strval(param);
if (countdown_seconds)
SendClientMessage(playerid,0xFF0000FF,"A countdown is already started.");
else if (seconds < 3 || seconds > 300)
SendClientMessage(playerid,0xFF0000FF,"You must enter a duration between 3 and 300.");
else
{
format(countdown_string,40,"You started a countdown of %d seconds.",seconds);
SendClientMessage(playerid,0x00FF00FF,countdown_string);
countdown_seconds = seconds+1;
}
return 1;
}
public countdown_timer()
{
if (countdown_seconds)
{
format(countdown_string,6,"~w~%d",countdown_seconds-1);
GameTextForAll(countdown_string,1100,4);
SoundForAll(1056);
countdown_seconds --;
if (!countdown_seconds)
{
GameTextForAll("~r~go !",2000,4);
SoundForAll(1057);
}
}
}
SoundForAll(sound)
{
for (new i = 0, j = GetMaxPlayers(); i < j; i ++)
if (IsPlayerConnected(i))
PlayerPlaySound(i,sound,0.0,0.0,0.0);
}
if (!seconds)
if (seconds < 1)
if (!countdown_seconds)
if (countdown_seconds < 1)