Quote:
Originally Posted by //exora
Strings in timers always mess up, I got the same issue.
|
well next one, i'm gonna check it.
w8 until i give here an edit of this post, i have some ideas in my head..
__
edit:
pawn Код:
#include <a_samp>
public OnFilterScriptInit(){
new string[256],packed[256];
format(string,256,"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789");
strpack(packed,string);
SetTimerEx("TheTestPublic",2000,0,"s",packed);
return 1;
}
forward TheTestPublic(source);// edit: lol forgot to add []... i'm gonna test this
public TheTestPublic(source){
new dSource[256];
format(dSource,256,"%s",source);
new unpacked[256];
strunpack(unpacked,dSource);
printf(dSource);
printf(unpacked);
return 1;
}
fail ;/
prints:
but i don't give up!
i try again with new an idea.
_
GOT IT!!!
just using arrays.. maybe u can do it in a other way but here is a simple solution:
pawn Код:
#include <a_samp>
#define MAX_SLOTS (10)
new
GlobalStringToSend[MAX_SLOTS][256],
IsSlotUsed[MAX_SLOTS] = {0,...};
public OnFilterScriptInit(){
new string[256];
format(string,256,"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789");
for(new slot;slot < MAX_SLOTS; slot++){
if(!IsSlotUsed[slot]){
GlobalStringToSend[slot] = string;
IsSlotUsed[slot] = 1;
SetTimerEx("TheTestPublic",2000,0,"i",slot);
return 1;
}
}
return 1;
}
forward TheTestPublic(slot);
public TheTestPublic(slot){
printf("%s",GlobalStringToSend[slot]);
IsSlotUsed[slot] = 0;
return 1;
}
study the code and let me know what you think about it.
so when the string arrives u can manipulate it as you want, so you can even "sent" strings up to 2048 characters without any problems.
but yea for 500 players just the ip has 16 chars so 500*16 = 8000, so we're making a "new string[8000];", lol.
so just to give u an idea
#define MAX_SLOTS MAX_PLAYERS .. ;]
and change [256] to [16]
__
next solution
:
(this works)
pawn Код:
public OnFilterScriptInit(){
new string[256],packed[256];
format(string,256,"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789");
strpack(packed,string);
printf(packed);
SetTimerEx("TheTestPublic",2000,0,"s",packed);
return 1;
}
forward TheTestPublic(source[]);
public TheTestPublic(source[]){
new dSource[256];
format(dSource,256,"%s",source);
new unpacked[256];
strunpack(unpacked,dSource);
printf(dSource);
printf(unpacked);
return 1;
}
now gonna test it without packing.
__
pawn Код:
public OnFilterScriptInit(){
new string[256];
format(string,256,"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789");
SetTimerEx("TheTestPublic",2000,0,"s",string);
return 1;
}
forward TheTestPublic(source[]);
public TheTestPublic(source[]){
new dSource[256];
format(dSource,256,"%s",source);
printf(dSource);
printf("%s",source);
return 1;
}
forward TheTestPublic2(const source[]);
public TheTestPublic2(const source[]){
new dSource[256];
format(dSource,256,"%s",source);
printf(dSource);
printf("%s",source);
return 1;
}
also works.. so i don't see any problems here lolz