SA-MP Forums Archive
Help with 2 commands.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with 2 commands.. (/showthread.php?tid=374000)



Help with 2 commands.. - Ruffian - 01.09.2012

How do I make this command to use in 10 minutes?

Код:
	if(strcmp(cmd, "/granades", true) == 0)
	{
		if (PlayerInfo[playerid][pDonateRank] >= 3)
		{
 			GivePlayerGun(playerid, 16);
		    GivePlayerMoney(playerid, -50000);
		    SendClientMessage(playerid, COLOR_GRAD1,"Ти закупи 10 гранати за 50,000$!");
		}
		else
		{
			SendClientMessage(playerid, COLOR_GRAD1,"ERROR: Ти не си вип или нямаш нужните права,за да използваш командата!");
		}
		return 1;
	}
What to do when a player write / afk can write / back after 1 minute?

Код:
  if(strcmp("/afk", cmdtext, true) == 0)
   {
   SendClientMessage(playerid, COLOR_YELLOW, "Сега си AFK, напиши /back за да се върнеш отново!");
   TogglePlayerControllable(playerid,0);
   label[playerid] = Create3DTextLabel("AFK",yellow,30.0,40.0,50.0,40.0,0);
   Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
   SetPlayerVirtualWorld(playerid, 28);
   new string3[70];
   new name[MAX_PLAYER_NAME];
   GetPlayerName(playerid, name, sizeof(name));

   format(string3, sizeof(string3), "%s отиде AFK!", name);
   SendClientMessageToAll(COLOR_YELLOW, string3);
   return 1;
   }

   if(strcmp("/back", cmdtext, true) == 0)
   {
   SendClientMessage(playerid, COLOR_YELLOW, "Ти се завърна!");
   TogglePlayerControllable(playerid,1);
   SetPlayerVirtualWorld(playerid, 0);
   new string3[70];
   new name[MAX_PLAYER_NAME];
   GetPlayerName(playerid, name, sizeof(name));

   format(string3, sizeof(string3), "%s се завърна!", name);
   SendClientMessageToAll(COLOR_YELLOW, string3);
   Delete3DTextLabel(Text3D:label[playerid]);
   return 1;
   }



Re: Help with 2 commands.. - Cjgogo - 01.09.2012

It's all about timers:https://sampwiki.blast.hk/wiki/SetTimerEx(WIKIPEDIA explains it well enough)


Re: Help with 2 commands.. - Ruffian - 01.09.2012

Do not open my page and I do not understand why timers want someone to do it for me!


Re: Help with 2 commands.. - MarkoN - 01.09.2012

its : https://sampwiki.blast.hk/wiki/SetTimerEx, i made an example, I'm not sure if it works but :
pawn Код:
// On top (with all of other forwards)
forward DonatorGranadeTimer(playerid);

// On top (with all your variables)
new granadesgiven[MAX_PLAYERS];

// Now we have to start the timer when he typed that command so
if(strcmp(cmd, "/granades", true) == 0)
    {
        if (PlayerInfo[playerid][pDonateRank] >= 3)
        {
            if(granadesgiven[playerid] == 0)
            {
            GivePlayerGun(playerid, 16);
            GivePlayerMoney(playerid, -50000);
            SendClientMessage(playerid, COLOR_GRAD1,"Oe зaeуie 10 a?aнaoe зa 50,000$!");
            SetTimerEx("DonatorGranadeTimer", 60000, 0, "i", playerid); // 60000 = 60 seconds = 1 minute
            granadesgiven[playerid] = 1;
            }
            else if(granadesgiven[playerid] == 1)
            {
            SendClientMessage(playerid, COLOR_GRAD1,"Plase wait 1 minute");
            }
        }
        return 1;
    }
   
// Now we need to set up a public for that timer
public DonatorGranadeTimer(playerid)
{
    granadesgiven[playerid] = 0;
    return 1;
}



Re: Help with 2 commands.. - Ruffian - 01.09.2012

Quote:
Originally Posted by MarkoN
Посмотреть сообщение
its : https://sampwiki.blast.hk/wiki/SetTimerEx, i made an example, I'm not sure if it works but :
pawn Код:
// On top (with all of other forwards)
forward DonatorGranadeTimer(playerid);

// On top (with all your variables)
new granadesgiven[MAX_PLAYERS];

// Now we have to start the timer when he typed that command so
if(strcmp(cmd, "/granades", true) == 0)
    {
        if (PlayerInfo[playerid][pDonateRank] >= 3)
        {
            if(granadesgiven[playerid] == 0)
            {
            GivePlayerGun(playerid, 16);
            GivePlayerMoney(playerid, -50000);
            SendClientMessage(playerid, COLOR_GRAD1,"Oe зaeуie 10 a?aнaoe зa 50,000$!");
            SetTimerEx("DonatorGranadeTimer", 60000, 0, "i", playerid); // 60000 = 60 seconds = 1 minute
            granadesgiven[playerid] = 1;
            }
            else if(granadesgiven[playerid] == 1)
            {
            SendClientMessage(playerid, COLOR_GRAD1,"Plase wait 1 minute");
            }

        return 1;
    }
   
// Now we need to set up a public for that timer
public DonatorGranadeTimer(playerid)
{
    granadesgiven[playerid] = 0;
    return 1;
}
LOL

Код:
C:\Users\ники\Desktop\gangwars.pwn(3514 -- 3519) : error 017: undefined symbol "PlayerName"
C:\Users\ники\Desktop\gangwars.pwn(3530) : error 017: undefined symbol "PlayerName"
C:\Users\ники\Desktop\gangwars.pwn(3700) : error 017: undefined symbol "ResetVars"
C:\Users\ники\Desktop\gangwars.pwn(4793) : error 017: undefined symbol "AntiDeAMX"
C:\Users\ники\Desktop\gangwars.pwn(4799) : error 004: function "FixHour" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(4818) : error 004: function "FixHour" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(4822) : error 017: undefined symbol "LoadFactions"
C:\Users\ники\Desktop\gangwars.pwn(5426) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5440) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5482) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5502) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5511) : error 017: undefined symbol "GivePlayerCash"
C:\Users\ники\Desktop\gangwars.pwn(5537) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5579) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5596) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5602) : error 017: undefined symbol "GivePlayerCash"
C:\Users\ники\Desktop\gangwars.pwn(5625) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5631) : error 017: undefined symbol "GivePlayerCash"
C:\Users\ники\Desktop\gangwars.pwn(5644) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5673) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(5682) : error 017: undefined symbol "GivePlayerCash"
C:\Users\ники\Desktop\gangwars.pwn(5695) : error 004: function "TimeTextForPlayer" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(6154) : error 017: undefined symbol "PlayerName"
C:\Users\ники\Desktop\gangwars.pwn(6175) : error 017: undefined symbol "ResetVars"
C:\Users\ники\Desktop\gangwars.pwn(6248) : error 004: function "SaveAccounts" is not implemented
C:\Users\ники\Desktop\gangwars.pwn(6275) : error 004: function "SaveAccounts" is not implemented

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.



Re: Help with 2 commands.. - MarkoN - 01.09.2012

those errors don't have anything to do with the script i gave you


Re: Help with 2 commands.. - Ruffian - 01.09.2012

When i delete the command,not give errors..


Re: Help with 2 commands.. - MarkoN - 01.09.2012

here you go:
pawn Код:
if(strcmp(cmd, "/granades", true) == 0)
    {
        if (PlayerInfo[playerid][pDonateRank] >= 3)
        {
            if(granadesgiven[playerid] == 0)
            {
            GivePlayerGun(playerid, 16);
            GivePlayerMoney(playerid, -50000);
            SendClientMessage(playerid, COLOR_GRAD1,"Oe зaeуie 10 a?aнaoe зa 50,000$!");
            SetTimerEx("DonatorGranadeTimer", 60000, 0, "i", playerid); // 60000 = 60 seconds = 1 minute
            granadesgiven[playerid] = 1;
            }
            else if(granadesgiven[playerid] == 1)
            {
            SendClientMessage(playerid, COLOR_GRAD1,"Plase wait 1 minute");
            }
        }
        return 1;
    }



Re: Help with 2 commands.. - Ruffian - 01.09.2012

And how to create on this timer for 2 minutes?

Код:
  if(strcmp("/afk", cmdtext, true) == 0)
   {
   SendClientMessage(playerid, COLOR_YELLOW, "Сега си AFK, напиши /back за да се върнеш отново!");
   TogglePlayerControllable(playerid,0);
   label[playerid] = Create3DTextLabel("AFK",yellow,30.0,40.0,50.0,40.0,0);
   Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
   SetPlayerVirtualWorld(playerid, 28);
   new string3[70];
   new name[MAX_PLAYER_NAME];
   GetPlayerName(playerid, name, sizeof(name));

   format(string3, sizeof(string3), "%s отиде AFK!", name);
   SendClientMessageToAll(COLOR_YELLOW, string3);
   return 1;
   }

   if(strcmp("/back", cmdtext, true) == 0)
   {
   SendClientMessage(playerid, COLOR_YELLOW, "Ти се завърна!");
   TogglePlayerControllable(playerid,1);
   SetPlayerVirtualWorld(playerid, 0);
   new string3[70];
   new name[MAX_PLAYER_NAME];
   GetPlayerName(playerid, name, sizeof(name));

   format(string3, sizeof(string3), "%s се завърна!", name);
   SendClientMessageToAll(COLOR_YELLOW, string3);
   Delete3DTextLabel(Text3D:label[playerid]);
   return 1;
   }



Re: Help with 2 commands.. - Cjgogo - 01.09.2012

Oh GOD,follow the example of the first command AND CREATE it for the second command,HE EVEN explained,that 60000 as param of the SetTimerEx function means 60 seconds,he showed you how to define a timer,FOLLOW THE example.