About Fast Event
#1

Can someone help me with a Fast event ? i want to add on my server but i'm not so exper to do it.
I finded this code but i don't know how to add on gamemode or where,can you help me with it?

new EventText[(10 + 1)]; //10 is the size of the text + 1 for the EOS mark (you can write 11, too)

---------------------------------------------------------------------------------------------------------

//Where you want to start the event (often used in some timer)
for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
EventText[c - 1] = ((random(2)) ? ((random(2)) ? ('a' + random(26)) : ('A' + random(26))) : ('0' + random(10)));
SendClientMessageToAll(0x0000FFAA, "***** Who types the word as fastest gets 10_000$:");
SendClientMessageToAll(0x0000FFAA, EventText);


-----------------------------------------------------------------------------------------------------------

//OnPlayerText
if(EventText[0] != EOS) //checks if the first cell isnt the end of the string
if(strcmp(text, EventText, false) == 0) //checks if the typed text match
{
SendClientMessage(playerid, 0xFFFFFFAA, "*** You were the fastest!");
GivePlayerMoney(playerid, 10_000);
EventText[0] = EOS; //sets the first cell to END OF STRING (mark it as empty)
}


-----------------------------------------------------------------------------------------------------------

So can you help me with this codes to add on gamemode,i just don't know where to add them...
Reply
#2

pawn Код:
new EventText[(10 + 1)]; //10 is the size of the text + 1 for the EOS mark (you can write 11, too)
Place that code under your includes.

pawn Код:
for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
EventText[c - 1] = ((random(2)) ? ((random(2)) ? ('a' + random(26)) : ('A' + random(26))) : ('0' + random(10)));
SendClientMessageToAll(0x0000FFAA, "***** Who types the word as fastest gets 10_000$:");
SendClientMessageToAll(0x0000FFAA, EventText);
I'm not familiar with the code above, so I guess you need to create a new public function for that. Create a new public function and place this code inside it, then just trigger the public function to start the event.

pawn Код:
if(EventText[0] != EOS) //checks if the first cell isnt the end of the string
if(strcmp(text, EventText, false) == 0) //checks if the typed text match
{
SendClientMessage(playerid, 0xFFFFFFAA, "*** You were the fastest!");
GivePlayerMoney(playerid, 10_000);
EventText[0] = EOS; //sets the first cell to END OF STRING (mark it as empty)
}
The comment in your source says it all, place this under public OnPlayerCommandText.
Reply
#3

I did that but it's give's me 2 errors,how to resolve them? :

/imageshack/img854/5493/45091877.png

/imageshack/img201/7758/73553721.png



Reply
#4

You probably placed something wrong. Can you copy past the code from the error lines, and also some code above and under it?
Reply
#5

First line :
----------------------------------------------------------------------------------------------------------------------

"
//================================================== ================================================== ================================================== =======
// = Include-uri
//================================================== ================================================== ================================================== =======
#include <a_samp>
#include <core>
#include <float>
#include <time>
#include <file>
#include <utils>
#include <morphinc>
#include <JunkBuster>
#include <ChatColor>
static gTeam[MAX_PLAYERS];
#define MAX_SWEARS 100
#define STR 100
new EventText[(10 + 1)]; //10 is the size of the text + 1 for the EOS mark (you can write 11, too)
//================================================== ================================================== ================================================== =======
// = JunkBusted
//================================================== ================================================== ================================================== =======
#define GetPlayerMoney JB_GetPlayerMoney
#define ResetPlayerMoney JB_ResetPlayerMoney
#define GivePlayerMoney JB_GivePlayerMoney
#define PutPlayerInVehicle JB_PutPlayerInVehicle
#define GivePlayerWeapon JB_GivePlayerWeapon
#define SetPlayerPos JB_SetPlayerPos
#define SetVehiclePos JB_SetVehiclePos

"

---------------------------------------------------------------------------------------------------------------------

Second line :

"
//================================================== ================================================== ================================================== =======
// = OnPlayerCommandText
//================================================== ================================================== ================================================== =======
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new cmd[256];
new tmp[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/healall", true) == 0)

{

GetPlayerName(playerid, sendername, sizeof(sendername));



if(IsPlayerConnected(playerid))

{

if(PlayerInfo[playerid][pAdmin] >= 2)

{

format(string, sizeof(string), "Administratorul %s a dat heal la toti playerii on.", sendername);

SendClientMessageToAll(0xFF7171FF, string);

for(new i = 0; i < MAX_PLAYERS; i ++)

{

if(IsPlayerConnected(i))

{

SetPlayerHealth(i, 100);

}

}

}

else

{

SendClientMessage(playerid, COLOR_RED, "Nu ai permisiunea pentru a folosit aceasta comanda!");

}

}

else

{

SendClientMessage(playerid, COLOR_RED, "Trebuie sa fi logat pentru a folosi aceasta comanda!");

}

return 1;

}

if(strcmp("/refresh", cmdtext, true, == 0)
{
SetPlayerVirtualWorld( playerid, 0 );
SetPlayerInterior( playerid, 0 );
//ResetPlayerWeapons( playerid );
//SetPlayerMoney( playerid, 0 );
//SetPlayerScore( playerid, 0 );
SetPlayerHealth( playerid, 100.0 );
return 1;
}

if(EventText[0] != EOS) //checks if the first cell isnt the end of the string
if(strcmp(text, EventText, false) == 0) //checks if the typed text match
{
SendClientMessage(playerid, 0xFFFFFFAA, "*** You were the fastest!");
GivePlayerMoney(playerid, 10_000);
EventText[0] = EOS; //sets the first cell to END OF STRING (mark it as empty)
}

"

--------------------------------------------------------------------------------------------------------------------

Third and last line :

"
//================================================== ================================================== ================================================== =======
// = MoveCamera
//================================================== ================================================== ================================================== =======
public MoveCamera(playerid)
{
SetPlayerCameraPos(playerid, player_x - 2 * floatsin(-PlayerInfo[playerid][SpawnAngle], degrees), player_y - 10 * floatcos(-PlayerInfo[playerid][SpawnAngle], degrees), player_z + 3);
SetPlayerCameraLookAt(playerid, player_x, player_y, player_z + 0.5);

PlayerInfo[playerid][SpawnAngle] += 0.5;

if (PlayerInfo[playerid][SpawnAngle] >= 360.0)
PlayerInfo[playerid][SpawnAngle] = 0.0;

}
//================================================== ================================================== ================================================== =======
// = ClearChatbox
//================================================== ================================================== ================================================== =======
public ClearChatbox(playerid, lines)
{
if (IsPlayerConnected(playerid))
{
for(new i=0; i<lines; i++)
{
SendClientMessage(playerid, COLOR_GREY, " ");
}
}
return 1;
}
//================================================== ================================================== ================
// fast event
//================================================== ================================================== =================
for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
EventText[c - 1] = ((random(2)) ? ((random(2)) ? ('a' + random(26)) : ('A' + random(26))) : ('0' + random(10)));
SendClientMessageToAll(0x0000FFAA, "***** Who types the word as fastest gets 10_000$:");
SendClientMessageToAll(0x0000FFAA, EventText);

"



Sorry,i didn't know how to add a code into a box with a scroolable bar.
Reply
#6

Shit -.-'' Did I say to place it under OnPlayerCommandText? My bad, really, sorry D: You need to place that under OnPlayerText, not under command text.
Reply
#7

Hehe,ok man,no problem.

It's giving me this error now,what's the problem?

pic : /imageshack/img29/7026/38881726.png

Reply
#8

Can you post that line of code again?
Btw, to add pawn code in a box, do [pawn ] [/pawn ] without the spaces after the word 'pawn'
Reply
#9

This is what is before fast event.

pawn Код:
//=============================================================================================================================================================
// = MoveCamera
//=============================================================================================================================================================
public MoveCamera(playerid)
{
    SetPlayerCameraPos(playerid, player_x - 2 * floatsin(-PlayerInfo[playerid][SpawnAngle], degrees), player_y - 10 * floatcos(-PlayerInfo[playerid][SpawnAngle], degrees), player_z + 3);
    SetPlayerCameraLookAt(playerid, player_x, player_y, player_z + 0.5);

    PlayerInfo[playerid][SpawnAngle] += 0.5;

    if (PlayerInfo[playerid][SpawnAngle] >= 360.0)
        PlayerInfo[playerid][SpawnAngle] = 0.0;

}
//=============================================================================================================================================================
// = ClearChatbox
//=============================================================================================================================================================
public ClearChatbox(playerid, lines)
{
    if (IsPlayerConnected(playerid))
    {
        for(new i=0; i<lines; i++)
        {
            SendClientMessage(playerid, COLOR_GREY, " ");
        }
    }
    return 1;
}
//====================================================================================================================
// fast event
//=====================================================================================================================
for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
EventText[c - 1] = ((random(2)) ? ((random(2)) ? ('a' + random(26)) : ('A' + random(26))) : ('0' + random(10)));
SendClientMessageToAll(0x0000FFAA, "***** Who types the word as fastest gets 10_000$:");
SendClientMessageToAll(0x0000FFAA, EventText);

Line of where is the error at 35789 is this :

pawn Код:
for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
Reply
#10

pawn Код:
forward TriggerEvent();
public TriggerEvent()
{
    for(new c = 1; c < sizeof EventText; c++) //fills the array with random letters or numbers
    EventText[c - 1] = ((random(2)) ? ((random(2)) ? ('a' + random(26)) : ('A' + random(26))) : ('0'+    random(10)));
   SendClientMessageToAll(0x0000FFAA, "***** Who types the word as fastest gets 10_000$:");
return 1;
}
Sorry for the ugly indentation, but sa-mp forum's reply box doesn't support 'tab' :P
Replace the thing below //fast event with the code above
SendClientMessageToAll(0x0000FFAA, EventText);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)