Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2012-09-02, 15:59


punek123







Wiek: 46
Na forum: 5026 dni
Posty: 7
Nick w MP: [SRL]Punki



Respekt: 50

Siema, to tak, przy konwertowaniu skryptu nie mia?em ?adnego b??du ani ostrze?enia. Problem pojawia si? gdy na serwerze zamelduje si? wi?cej ni? jeden gracz. Wygl?da to tak, ?e ka?dy gracz z id wy?szym ni? 0 dostaje nick gracza, kt?ry ma id 0, z tym, ?e gracz o nicku id 0 widzi nicki innych normalnie.
Kod:

#include <a_samp>

#define MAX_MESSAGES 100

#define TIMER 60000

#define COLOR_BOT 0x0099EEFF

new BotName[24] = "Leszczu";
new RANDOMMSG = 1;
new MAXMESSAGE;
new BOTMESSAGE[MAX_PLAYERS][128];

forward Random(playerid);

new RandomMsg[][] =
{
"Niech k**** siadaj? nie b?d? przecie? sta?y",
"Nie p?kaj bracie bo p?kaj? gacie",
"Raz dwa trzy wypierdalamy drzwi ",
"k**** ta?cz? jak im zagram "
};

public OnFilterScriptInit()
{
if(RANDOMMSG == 1)
{
SetTimer("SendRandomMessage",TIMER,1);
}

AddRandomMessage("Niech k**** siadaj? nie b?d? przecie? sta?y");
AddRandomMessage("Nie p?kaj bracie bo p?kaj? gacie");
AddRandomMessage("Raz dwa trzy wypierdalamy drzwi");
AddRandomMessage("k**** ta?cz? jak im zagram");
AddRandomMessage("Jest melina i posypana kokaina");
AddRandomMessage("Dziwki w?a?nie przyjecha?y i opierdalaj? ga?y");
AddRandomMessage("Lecimy na bogato ***** szmato");


print("Shadow's Chatbot Loaded");
return 1;
}

public OnPlayerConnect(playerid)
{
SendBotMessage("Yo? k*** jest balanga u leszcza");
return 1;
}

forward SendRandomMessage();
public SendRandomMessage()
{
for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
{
if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
{
new pName[18];
format(pName,sizeof(pName),"%s",PlayerName(playerid));
new ColorSave = GetPlayerColor(playerid);
SetPlayerColor(playerid,COLOR_BOT);
SetPlayerName(playerid,BotName);
SendPlayerMessageToAll(playerid,BOTMESSAGE[random(MAXMESSAGE)]);
SetPlayerColor(playerid,ColorSave);
SetPlayerName(playerid,pName);
return 1;
}
}
return 1;
}

forward SendBotMessage(msg[]);
public SendBotMessage(msg[])
{
for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
{
if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
{
new pName[18];
format(pName,sizeof(pName),"%s",PlayerName(playerid));
new ColorSave = GetPlayerColor(playerid);
SetPlayerColor(playerid,COLOR_BOT);
SetPlayerName(playerid,BotName);
SendPlayerMessageToAll(playerid,msg);
SetPlayerColor(playerid,ColorSave);
SetPlayerName(playerid,pName);
return 1;
}
}
return 1;
}

stock AddRandomMessage(msg[])
{
format(BOTMESSAGE[MAXMESSAGE],128,"%s",msg);
MAXMESSAGE++;
return 1;
}

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

public OnPlayerText(playerid, text[])
{
if(!strcmp(text, "siema", true) || !strcmp(text, "elo", true) || !strcmp(text, "czesc", true) || !strcmp(text, "witam", true))
{
SendPlayerMessageToAll(playerid, text);
SendBotMessage("Siema. Tu Leszczu zaraz rozpalamy grila");
return 0;
}

if(!strcmp(text, "Hi", true) || !strcmp(text, "Sup", true) || !strcmp(text, "Sophie", true) || !strcmp(text, "Hiya", true))
{
SendPlayerMessageToAll(playerid, text);
Random(playerid);
return 0;
}

return 1;
}

public Random(playerid)
{
new str[128];
new randMSG = random(sizeof(RandomMsg));
format(str, sizeof(str), "%s %s", RandomMsg[randMSG], PlayerName(playerid));
SendBotMessage(str);
return 1;
}


P.S; Nie uzywa?em demax'a. Kod znalaz?em na oficjalnym forum sampa i udost?pni? go autor, ja przerobi?em go tylko pod siebie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2012-09-02, 17:29


Combacior







Wiek: 29
Na forum: 5795 dni
Posty: 1516

Piwa: 2161

Respekt: 1060
Respekt: 1060

Ostrzeżeń: 20%
Kod:

forward SendBotMessage(msg[]);
public SendBotMessage(msg[])
{
for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
{
if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
{
new pName[18];
format(pName,sizeof(pName),"%s",PlayerName(playerid));
new ColorSave = GetPlayerColor(playerid);
SetPlayerColor(playerid,COLOR_BOT);
SendPlayerMessageToAll(playerid,msg);
return 1;
}
}
return 1;


Postaw piwo autorowi tego posta
 

 
Wysłany: 2012-09-02, 17:42


punek123







Wiek: 46
Na forum: 5026 dni
Posty: 7
Nick w MP: [SRL]Punki



Respekt: 50

"CombaT" napisał/a:

Kod:

forward SendBotMessage(msg[]);
public SendBotMessage(msg[])
{
for(new playerid=0;playerid<MAX_PLAYERS;playerid++)
{
if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)
{
new pName[18];
format(pName,sizeof(pName),"%s",PlayerName(playerid));
new ColorSave = GetPlayerColor(playerid);
SetPlayerColor(playerid,COLOR_BOT);
SendPlayerMessageToAll(playerid,msg);
return 1;
}
}
return 1;



C:\Users\Real Madrid\Desktop\nowyleszcz.pwn(94) : error 021: symbol already defined: "SendBotMessage"
C:\Users\Real Madrid\Desktop\as.txt(101) : warning 204: symbol is assigned a value that is never used: "ColorSave"
C:\Users\Real Madrid\Desktop\as.txt(101 -- 107) : warning 217: loose indentation


edit znalaz?em co? takiego na forum jako pomoc w rozwi?zaniu b??du tego samego nicku

Kod:



Code:
if(IsPlayerConnected(playerid)==1 && GetPlayerColor(playerid) != 0)

As explained by SA-MP, if a player doesn't have his colour changed by the script (SetPlayerColor), the players colour will be 0.

Just use a integer, when the player connects check if it's a bot (strcmp it's name), then set the integer (im_a_bot)to the playerid.
Kod:


new im_a_bot = -1;
Code:
public OnPlayerConnect(playerid)
{
if(strcmp("Rac3r(Bot)", PlayerName(playerid), true)==0)im_a_bot = playerid;
return 1; // end of code, obviously
}

Then, instead of a MAX_PLAYERS loop, just use:
Kod:


public SendBotMessage(msg[])
{
if(im_a_bot != -1)
{
new pName[18];
format(pName,sizeof(pName),"%s",PlayerName(im_a_bot));
.....// and so on;

Use your head, make a check OnPlayerDisconnect, if the chatting bot disconnects, set im_a_bot to -1.

M?g?by kto? mi pom?c to wpasowa? w m?j kod ? Jestem zielony i po prostu pr?buj? ale mi to nie wychodzi ;/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2012-09-02, 19:57


Combacior







Wiek: 29
Na forum: 5795 dni
Posty: 1516

Piwa: 2161

Respekt: 1060
Respekt: 1060

Ostrzeżeń: 20%
"punek123" napisał/a:

C:\Users\Real Madrid\Desktop\nowyleszcz.pwn(94) : error 021: symbol already defined: "SendBotMessage"
C:\Users\Real Madrid\Desktop\as.txt(101) : warning 204: symbol is assigned a value that is never used: "ColorSave"
C:\Users\Real Madrid\Desktop\as.txt(101 -- 107) : warning 217: loose indentation


Co to ma w og?le by?? Warningi z pliku .txt w pawno? Po drugie m?j kod jest dobry, tylko ty go doda?e?, a mia?e? go zamieni? ze swoim. Oj nie poci?gniesz daleko w pawn, do tego potrzebne jest logiczne my?lenie i podstawowa znajomo?? angielskiego.

Postaw piwo autorowi tego posta
 

 
Tagi: wszyscy :: mają :: ten :: sam :: nick
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » PAWN Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku