Need help with a little command.
#1

Код:
new typed[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	if(typed[playerid] = 1)
	{
	for(new i = 0;i < MAX_PLAYERS; i++)
 			{
 			ShowPlayerNameTagForPlayer(playerid, i, 1);
			}
	return 1;

	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/achucknorris", cmdtext, true, 10) == 0)
	{
    SendClientMessage(playerid, COLOR_GREEN, "You are now Chuck Norris - name tag disabled, skin changed, health 10000000, weapons given");
    SetPlayerSkin(playerid, 294);
    GivePlayerWeapon(playerid, 26, 100000);
    GivePlayerWeapon(playerid, 34, 100000);
    GivePlayerWeapon(playerid, 35, 100000);
    GivePlayerWeapon(playerid, 4, 1);
    SetPlayerHealth(playerid, 100000000.0);
    typed[playerid] = 1;
	}
	return 1;
}
Why does this not work? I want the playerґs name tag disabled as he enters the command..
Reply
#2

Because if this

Код:
if(typed[playerid] = 1)
is under OnPlayerConnect, how will the script know the player is 1? Let's try and fix this ...

You should probably put this in a function and set a timer on it to check every second.

Example:

Код:
forward ChuckNorris();
public CheckNorris()
{
   for(new i = 0;i < MAX_PLAYERS; i++)
   {
      if(typed[i] = 1)
 	  ShowPlayerNameTagForPlayer(playerid, i, 0); // Will hide it
      return 1;
   }

}
return 1;
}
Something like that .. and set a timer on it on OnGameModeInit. All the other code is fine in the command. Nothing need go under OnPlayerConnect apart from maybe
Код:
typed[playerid] =0;
Reply
#3

What would be the whole script then? Iґm new to this crap and its pretty hard.
Reply
#4

Quote:
Originally Posted by Mo3
What would be the whole script then? Iґm new to this crap and its pretty hard.
Lol I'm new myself, only had about 2 months experience, but it becomes easier :+

So basically, add this at the bottom of your script.

Код:
forward ChuckNorris();
public CheckNorris()
{
   for(new i = 0;i < MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i))
      {
        if(typed[i] == 1)
 	    ShowPlayerNameTagForPlayer(i, 0); // Will hide it
        return 1;
      }
   }
}
return 1;
}
Add this under OnPlayerConnect, OnPlayerDisconnect:

Код:
typed[playerid] =0;
The original command code you posted was fine so just use that, theres nothing much wrong with it.

Add this under OnGameModeInit or if it's a filterscript .. add under OnFilterScriptInit:

Код:
SetTimer("ChuckNorris",1000,1);
That's about it ... indentation will need to be fixed for your tabsize because SMF fucks it up.
Reply
#5

Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(17) : error 017: undefined symbol "typed"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(17) : warning 215: expression has no effect
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(17) : error 001: expected token: ";", but found "]"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(17) : error 029: invalid expression, assumed zero
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(17) : fatal error 107: too many error messages on one line
Reply
#6

lol okay put this at the top of your script ...

Код:
new typed[MAX_PLAYERS];
Reply
#7

Код:
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(28) : warning 235: public function lacks forward declaration (symbol "CheckNorris")
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(35) : warning 202: number of arguments does not match definition
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(39) : warning 209: function "CheckNorris" should return a value
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(40) : error 010: invalid function or declaration
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(56) : error 017: undefined symbol "getippt"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(56) : warning 215: expression has no effect
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(56) : error 001: expected token: ";", but found "]"
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(56) : error 029: invalid expression, assumed zero
C:\Dokumente und Einstellungen\Moritz\Desktop\WW3\chucknorris.pwn(56) : fatal error 107: too many error messages on one line
LMAO!!!
Reply
#8

Lol okay, this is usually what happens with PAWNO it will go through each set of errors separately.

Ok so .. first error:

Is my fault, it was a typo .. see third error

Second Error:

Show me line 35.

Third error:

Copy and paste this over the existing ChuckNorrris function

Код:
forward ChuckNorris();
public CheckNorris()
{
   for(new i = 0;i < MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i))
      {
        if(typed[i] == 1)
 	    ShowPlayerNameTagForPlayer(i, 0); // Will hide it
        return 1;
      }
   }
   return 1;
}
4th error: Show me line 40.

5th and final error: Show me line 56 .. and what is gettippt?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)