Jump to content
  • 0

pomoc Pomoc Random Textu


Patricl0n

Dotaz

Mam problem:

Jsem začatnik pawna ale nevím jakou tam mam chybu tak prosím o pomoc.

 

 error 047: array sizes do not match, or destination array is too small

 

public RandomText(){
new string[30], str[256];
format(string, sizeof(string), "%s%s%s%s%s%s%s%s%s%s"
, LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]
, LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]
, LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]
, LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]
, LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]); // 10 random písmen
        RandText = string; //uloží písmena na RandText
        RText=1;
        format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text '' %s '' získá náhodnou částku.",RandText);
SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráče
return true;
}
Link to comment
Share on other sites

8 odpovědí na tuto otázku

Recommended Posts

  • 0

stock randomStr(data[], size) {
     for(new i = 0; i < size; ++i) {
         dataLetterList[random(sizeof(LetterList))];
     }
     data = '\0';    
}
 

public RandomText(){
new random[11], str[256];
randomStr(random, 10);
 
        RandText = random; //uloží písmena na RandText, RandText musi byt aspom 11 velky! Nemozes dat vacsi text do mensieho

        

        RText=1;format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text '' %s '' získá náhodnou částku.",random);
SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráče
return true;
}
Edited by xhunterx
Link to comment
Share on other sites

  • 0

Ted mi to pise:

 

error 076: syntax error in the expression, or invalid function call

 

 

 RText=1;format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text '' %s '' získá náhodnou částku.",random);
SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráče
return true;
}
Link to comment
Share on other sites

  • 0

Sorry, som si to neskopiroval do pawna, skus takto

 

stock randomStr(data[], size) {
    for(new i = 0; i < size; ++i) {
        data[i] = LetterList[random(sizeof(LetterList))];
    }
    data[size] = '\0';
}

RandomText();
public RandomText(){
    new rand[11], str[256];
    randomStr(rand, 10);

    RandText = rand; //uloží písmena na RandText, RandText musi byt aspom 11 velky! Nemozes dat vacsi text do mensieho

    RText=1;
    format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text \"%s\" získá náhodnou cástku.",rand);
    SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráce
    return true;
}
Edited by xhunterx
Link to comment
Share on other sites

  • 0

ted mi to pise:

 

 

error 047: array sizes do not match, or destination array is too small

error 017: undefined symbol "PlayerName"

error 006: must be assigned to an array

 

mozna to je trapny ale moc se nevyznam v pawno tak mne prosim nesud

Link to comment
Share on other sites

  • 0

ted mi to pise:

 

 

error 047: array sizes do not match, or destination array is too small

error 017: undefined symbol "PlayerName"

error 006: must be assigned to an array

 

mozna to je trapny ale moc se nevyznam v pawno tak mne prosim nesud

hod sem cely mod

Link to comment
Share on other sites

  • 0

ok posilam script na Random Text ale prosim poradte mi

 

 

 

#include <a_samp>
 
#pragma tabsize 0
 
new RandText[10]; //samotný text má 10 písmen max můžete si přidat/měnit potom ale nezapomente zmenit aj cisla
new LetterList[26][] = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
}; // seznam písmen
new RText=0;
 
forward RandomText(); //forward pro publick RandomText
 
public OnFilterScriptInit(){
SetTimer("RandomText", 5*60000, true); //timer
return true;
}
 
stock randomStr(data[], size) {
    for(new i = 0; i < size; ++i) {
    data[i] = LetterList[random(sizeof(LetterList))];
    }
    data[size] = '\0';
}
 
RandomText();
public RandomText(){
    new rand[11], str[256];
    randomStr(rand, 10);
 
    RandText = rand; //uloží písmena na RandText, RandText musi byt aspom 11 velky! Nemozes dat vacsi text do mensieho
 
    RText=1;
    format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text \"%s\" získá náhodnou cástku.",rand);
    SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráce
    return true;
}
public OnFilterScriptExit(){
return true;
}
 
public OnPlayerText(playerid, text[]){
new string[256];
new cash = random(50000); //náhodný cash od 0 do 50 000 je lepší použít RandomEx (najdete na samp foru) a nastavit si třeba od 5000 do 1500
if(RText == 1){ //pokud je RaText na 1 bude to reagovat
if(!strcmp(text, RandText, true)){ //zjistí jestli někdo napsal ten text
format(string, sizeof(string), "[ {C2A2DA}Text{FFFFFF} ] Jako první napsal náhodný text '' %s '' hráč %s a získal {33AA33}$%d{FFFFFF}.",RandText,PlayerName(playerid),cash);
SendClientMessageToAll(-1,string); //vypíše zprávu pro všechny hráče
GivePlayerMoney(playerid, cash); //dá tomu co napsal jako první cash
       RText=0;
}
 
}
return true;
}

 

 

//vEnd: Příště prosím použij BB kód code a spoiler. Děkuji.

Link to comment
Share on other sites

  • 0


#include <a_samp>

new LetterList[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
new RandText[10];

public OnFilterScriptInit()
{
SetTimer("RandomText",5*60_000,1);
return 1;
}

public OnPlayerText(playerid,text[])
{
if(RandText[0] && strcmp(text,RandText,true) == 0)
{
new string[144],cash = random(50_000);
format(string,sizeof(string),"[ {C2A2DA}Text{FFFFFF} ] Jako první napsal náhodný text \"%s\" hráč %s a získal {33AA33}$%d{FFFFFF}.",RandText,PlayerName(playerid),cash);
SendClientMessageToAll(-1,string);
GivePlayerMoney(playerid,cash);
RandText[0] = 0;
                //return 0;//chces to co opisuje odeslat do chatu ?
}
return 1;
}

forward RandomText();
public RandomText()
{
RandomString(RandText);
new str[144];
format(str,sizeof(str),"[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text \"%s\" získá náhodnou cástku.",RandText);
SendClientMessageToAll(-1,str);
return 1;
}

stock RandomString(data[],size = sizeof(data))
{
for(new i;i<size;i++) data[i] = LetterList[random(sizeof(LetterList))];
data[size] = 0;
return 1;
}

stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}

 

Edited by ATomas
  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...