Variable problem (New in pawno)
#1

Well i've just started today, and i'm learning the basics from wiki-samp and some tutorials from sa-mp forums... Hm well today i wanted to make that when a player connects it sends him a message saying welcome to the server SendClientMessage and %s Has joined the server SendClientMessageToAll, That code is fine... but i tried to make an integer..

Here the code.

Код:
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}
{
new Year2012 = 7;
printf("Year2012: %d", Year2012);
Year2012 = 14;
printf("Year2012: %d", Year2012);
return 1;
}

public OnFilterScriptExit()
{
	return 1;
}
public OnPlayerConnect(playerid)

{
	new string[128];
	new Pname[24];
	GetPlayerName(playerid,Pname,sizeof(Pname)); 
	format(string,sizeof(string),"%s has joined the server",Pname); 
	SendClientMessage(playerid,0x0000FFFF, "Welcome to the server");
	SendClientMessageToAll(0x000FFFFF,string);
	return 1;
}

  Year2012[14];
   Pname[24];
   GetPlayerName(playerid,Pname,sizeof(Pname));
   format(Year2012,sizeof(Year2012),"Hello %s you're currently on %d enjoy the end of the world",Pname,Year2012);
   SendClientMessage(playerid,0x0000F0F0,Pname,Year2012);
   
   return 1;
}
And it gives me those two errors

Код:
C:\Users\Guille\Desktop\Server\gamemodes\Newshit.pwn(73) : error 010: invalid function or declaration
C:\Users\Guille\Desktop\Server\gamemodes\Newshit.pwn(79) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
If anyone could simply explain me what i did wrong there i'd be thankful to you.. I'm trying to learn.

Thank you for caring
Reply
#2

pawn Код:
{
new Year2012 = 7;
printf("Year2012: %d", Year2012);
Year2012 = 14;
printf("Year2012: %d", Year2012);
return 1;
}
You must declare this as a function instead of just placing braces.
Like this:
pawn Код:
stock funcName() {
new Year2012 = 7;
printf("Year2012: %d", Year2012);
Year2012 = 14;
printf("Year2012: %d", Year2012);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)