#1

Behave that I'm new to PAWN.

So, what I'm trying to do is simply print how long a guy has survived, but it doesnt seem to allow me to run the "/startround" command, and I don't know how to increase the new "count" variable.


pawn Код:
// New variables
new count=0;

// Forwards
forward SurvivedTime(playerid);


public SurvivedTime(playerid)
{
    count + 1; // expression has no effect
    printf("The murderer has stayed alive for %d seconds!", count);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
 if(strcmp(cmdtext, "/startround", true))
 {
 SetTimerEx("SurvivedTime", 1000, false, "is", 1337, "hello!");
 return 1;
 }
 return 0;
}
Reply
#2

pawn Код:
count = count + 1;
//OR
count+= 1;
//OR
count++;
Reply
#3

try: SetTimerEx("SurvivedTime", 1000, true, "i", playerid");
Reply
#4

Okay, I tried both. The only problem now, is that the command "/startround" still is a "Unknown Command"
Reply
#5

pawn Код:
if(strcmp(cmdtext, "/startround", true) == 0)
{
    SetTimerEx("SurvivedTime", 1000, false, "is", 1337, "hello!");
    return 1;
}
Reply
#6

Ah, I fixed it! I simply edited it like this:
pawn Код:
if(strcmp(cmdtext, "/startround", true) == 0)
EDIT: You got the point :P
Reply
#7

How could I get the count between those two bracles?

pawn Код:
SendClientMessage(playerid, COLOR_GREEN, "The murderer has stayed alive for " & count & " seconds!");
Reply
#8

Use format.
Reply
#9

Okay, thanks!
Reply
#10

I can't be assed to create multiple threads, so heres another question:

I got everything working, besides when the text updates, it draws upon the old text.

pawn Код:
new count;
new newCount[128];
new Text:mytext;

public SurvivedTime(playerid)
{
    count = count + 1;
   
    format(newCount,sizeof(newCount), "The murderer has stayed alive for %d seconds!",count);
       
    mytext = TextDrawCreate(150.0,380.0,newCount); // Create the textdraw
    TextDrawColor(mytext, COLOR_YELLOW); // Set the color of the text
    TextDrawSetOutline(mytext,1); // Set the outline (stroke) of the text
    TextDrawSetShadow(mytext,0); // Set the shadow of the text
    TextDrawFont(mytext,2); // Set the Font
    TextDrawLetterSize(mytext,0.3,0.8); // Set the letter size
    TextDrawShowForPlayer(playerid,mytext); // Show the textdraw to a certain player
   
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
 if(strcmp(cmdtext, "/startround", true) == 0){
 SetTimerEx("SurvivedTime", 1000, true, "i", playerid);
 return 1;
 }
 return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)