SA-MP Forums Archive
is this a Right Code? - 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: is this a Right Code? (/showthread.php?tid=334578)



is this a Right Code? - Andrew97 - 15.04.2012

I want to Count the players that online and Print the Number when any Player Joines!

Код:
new players 
public onplayerconnect
{    
 	players+=1;
 	printf("there are Currently %d online",players);
        public OnPlayerDisconnect(playerid, reason)
}    return 1;


{

 	players--;
    printf("there are currently %d players online ",players);

	return 1;
}



Re: is this a Right Code? - Andrew97 - 15.04.2012

It Compiles and everything is good but Nothing happen IG


Re: is this a Right Code? - fordawinzz - 15.04.2012

pawn Код:
new players = 0;

public OnPlayerConnect(playerid)
{
     players++;
     printf("There are currently %d players online.", players);
     return 1;
}
public OnPlayerDisconnect(playerid)
{
     players--;
     printf("There are currently %d players online.", players);
     return 1;
}
This is a right example.


Re: is this a Right Code? - Andrew97 - 15.04.2012

Why it Doesn't Print IG that there is ** players ?

Another thing:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/welcome", cmdtext, true, 10) == 0)
    SendClientMessageToAll(RED,"Welcome");
     

	return 0;
}
The CMD works Perfectly but it says Unknown COmmande but it works! what is this Means?


Re: is this a Right Code? - [HiC]TheKiller - 15.04.2012

Have you got
pawn Код:
#if defined FILTERSCRIPT
anywhere? If so, delete that and your code might work. The code that you have in your first post would have given errors unless you had an if defined that made the compiler skip the errors.

EDIT: I also just saw that you want it to show ingame. Use format + SendClientMessageToAll to do this rather than print.


Re: is this a Right Code? - Andrew97 - 15.04.2012

No In Both Codes 0 Errors but In the FIrst Nothing Happen! and in the Second The CMD works Perfectly but it tells me Unknown Command what is this Means?


Re: is this a Right Code? - [HiC]TheKiller - 15.04.2012

pawn Код:
if (strcmp("/welcome", cmdtext, true) == 0) return SendClientMessageToAll(RED,"Welcome");
or
pawn Код:
if (strcmp("/welcome", cmdtext, true) == 0)
{
    SendClientMessageToAll(RED,"Welcome");
    return 1;
}
You must return 1, or it will return 0 which is unknown command.


Re: is this a Right Code? - Andrew97 - 15.04.2012

Maybe this Helpes you to Find the Problem?:



[Code]#include <a_samp>
#include <a_http>
#include <a_Npc>
#include <a_objects>
#include <a_players>
#include <a_sampdb>
#include <a_vehicles>
#include <core>
#include <Datagram>
#include <file>
#include <float>
#include <String>
#include <time>



#define RED 0xff000ff
#define GREY 0xAFAFAFAA
#define WHITE 0xFFFFFFAA
#define YELLOW 0xFFFF00AA
#define LIGHTBLUE 0x33CCFFAA
#define LIGHTGREEN 0x9ACD32AA
#define BLUE 0x5A8CA5AA
#define GREEN 0x33AA33AA
#define PURPLE 0xC2A2DAAA
#define COLOR_OTHER 0xFF6347AA
#define ORANGE 0xFF8C00AA
#define COLOR_DMV 0xFF0000F
#define COLOR_DMV2 0xaa3333AA
new players = 0;
new cars= 0;[/QUOTE]


Re: is this a Right Code? - Andrew97 - 15.04.2012

why in the First Code Nothing Happened IG and in the Script 0 Error

@specialKiller Thank you very Much for helping me!!!


Re: is this a Right Code? - Andrew97 - 15.04.2012

Anyone please help me