SA-MP Forums Archive
Give something for couple seconds - 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: Give something for couple seconds (/showthread.php?tid=619331)



Give something for couple seconds - henkas - 16.10.2016

I have one question how need give something for couple seconds like
Код:
	if(PRESSED(KEY_WALK))
 	{
 	    if(team[playerid] == TEAM_ZOMBIE)
 	    {
  			if(pInfo[playerid][pZombieClass] == ROGUEZOMBIE)
  			{
  			    if(gettime() - 60 < Abilitys[playerid][ChangeSkinZombie]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
  			    {
                    Abilitys[playerid][ChangeSkinZombie] = gettime();
                    SetPlayerColor(playerid,COLOR_HUMAN);
		            switch(random(5))
		            {
		            case 0: SetPlayerSkin(playerid,5);
		            case 1: SetPlayerSkin(playerid,23);
		            case 2: SetPlayerSkin(playerid,56);
		            case 3: SetPlayerSkin(playerid,289);
		            case 4: SetPlayerSkin(playerid,299);
				}
                    
				}
			}
		}
	}
This function work now when i press l-alt i get random skin and name color, bat i want make now, when over like 30seconds everything going back, my regular skin,nick color.

bumbumbum


Respuesta: Give something for couple seconds - Zume - 16.10.2016

PHP код:
if(gettime() - 60 Abilitys[playerid][ChangeSkinZombie]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5); 
This is a error, why? if you have more keys with the same key in this callback below this not won't be executed

And you can return name and skin to player with some like this:

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
PRESSED(KEY_WALK)) {
         if(
team[playerid] == TEAM_ZOMBIE && pInfo[playerid][pZombieClass] == ROGUEZOMBIE) {
              if(
Abilitys[playerid][ChangeSkinZombie] < gettime()){
                
SetPVarInt(playerid"afterColor"GetPlayerColor(playerid));
                
SetPVarInt(playerid"afterSkin"GetPlayerSkin(playerid));
                
                
Abilitys[playerid][ChangeSkinZombie] = gettime() + 60;
                
SetPlayerColor(playeridCOLOR_HUMAN);
                static 
RandomHumanSkin[] = { 
                    
52356289299
                
};
                
SetPlayerSkin(playeridRandomHumanSkin[random(sizeof(RandomHumanSkin) - 1)]); // now you don't need to specify quantities
                
SetTimerEx("ReturnBack"1000*30false"i"playerid);
              } else {
                  
GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
              }
        }
    }
    return 
1;
}
forward ReturnBack(playerid);
public 
ReturnBack(playerid)
{
    
SetPlayerSkin(playeridGetPVarInt("afterSkin"));
    
SetPlayerColor(playeridGetPVarInt("afterColor"));
    return 
1;

But GetPlayerColor only works if you used SetPlayerColor before


Re: Respuesta: Give something for couple seconds - henkas - 17.10.2016

Quote:
Originally Posted by Zume
Посмотреть сообщение
PHP код:
if(gettime() - 60 Abilitys[playerid][ChangeSkinZombie]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5); 
This is a error, why? if you have more keys with the same key in this callback below this not won't be executed

And you can return name and skin to player with some like this:

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
PRESSED(KEY_WALK)) {
         if(
team[playerid] == TEAM_ZOMBIE && pInfo[playerid][pZombieClass] == ROGUEZOMBIE) {
              if(
Abilitys[playerid][ChangeSkinZombie] < gettime()){
                
SetPVarInt(playerid"afterColor"GetPlayerColor(playerid));
                
SetPVarInt(playerid"afterSkin"GetPlayerSkin(playerid));
                
                
Abilitys[playerid][ChangeSkinZombie] = gettime() + 60;
                
SetPlayerColor(playeridCOLOR_HUMAN);
                static 
RandomHumanSkin[] = { 
                    
52356289299
                
};
                
SetPlayerSkin(playeridRandomHumanSkin[random(sizeof(RandomHumanSkin) - 1)]); // now you don't need to specify quantities
                
SetTimerEx("ReturnBack"1000*30false"i"playerid);
              } else {
                  
GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
              }
        }
    }
    return 
1;
}
forward ReturnBack(playerid);
public 
ReturnBack(playerid)
{
    
SetPlayerSkin(playeridGetPVarInt("afterSkin"));
    
SetPlayerColor(playeridGetPVarInt("afterColor"));
    return 
1;

But GetPlayerColor only works if you used SetPlayerColor before
Got these error
error 035: argument type mismatch (argument 1)
at this lines
Код:
    SetPlayerSkin(playerid, GetPVarInt("afterSkin"));

    SetPlayerColor(playerid, GetPVarInt("afterColor"));



Re: Give something for couple seconds - henkas - 17.10.2016

Help fix these errors.


Re: Give something for couple seconds - henkas - 17.10.2016

How should i fix this error?


Re: Give something for couple seconds - henkas - 17.10.2016

Got these error
error 035: argument type mismatch (argument 1)
at this lines
Code:
SetPlayerSkin(playerid, GetPVarInt("afterSkin"));

SetPlayerColor(playerid, GetPVarInt("afterColor"));


Re: Give something for couple seconds - jlalt - 17.10.2016

https://sampwiki.blast.hk/wiki/GetPVarInt
PHP код:
GetPVarInt(playeridvarname[]); 
PHP код:
forward ReturnBack(playerid); 
public 
ReturnBack(playerid

    
SetPlayerSkin(playeridGetPVarInt(playerid"afterSkin")); 

    
SetPlayerColor(playeridGetPVarInt(playerid"afterColor")); 
    return 
1




Re: Give something for couple seconds - henkas - 17.10.2016

Quote:
Originally Posted by jlalt
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/GetPVarInt
PHP код:
GetPVarInt(playeridvarname[]); 
PHP код:
forward ReturnBack(playerid); 
public 
ReturnBack(playerid

    
SetPlayerSkin(playeridGetPVarInt(playerid"afterSkin")); 
    
SetPlayerColor(playeridGetPVarInt(playerid"afterColor")); 
    return 
1

Thanks a lot. Done with this.