02.04.2010, 13:52
idk where is problem :S but i know when i connect in my server i can type example "sdafjbs" but when i use command example "/help" nothing happen :-/ can someone help me...
Originally Posted by !Vampire!
idk that happend to me once , but i stopped using strtok and strcmp , try using dcmd and sscanf its alot better
|
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd (fill, 4, cmdtext);
dcmd (buyfuel, 7, cmdtext);
dcmd (usefuel, 7, cmdtext);
dcmd(rob, 3, cmdtext);
dcmd(napunisve, 9, cmdtext);
dcmd(me, 2, cmdtext);
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new cmd[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
if (strcmp("/pomoc", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Pomoc","Na serveru se nalazi puno stvari\n-Kuce\n-Droga\n-DM arene\n-Drag raceovi\nI jako puno drugih stvari, za listu komanda napisi /komande","OK","Odustani");
return 1;
}
if (strcmp("/test", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid,418.895020, 2551.045166, 19.878103);
return 1;
}
if(!strcmp(cmdtext, "/pm", true))
{
ShowPlayerDialog(playerid,755,DIALOG_STYLE_INPUT,"Extreme Fun Server Privatna poruka","Upisi ID igraca kojem zelis poslati poruku:","Dalje","Odustani");
return 1;
}
new tmp[256];
/*new Message[256];
new gMessage[256];
new pName[MAX_PLAYER_NAME+1];
new iName[MAX_PLAYER_NAME+1];*/
/*if(strcmp("/pm", cmd, true) == 0)
{
if(!strlen(tmp) || strlen(tmp) > 5) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
return 1;
}
new id = strval(tmp);
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
return 1;
}
if(!IsPlayerConnected(id)) {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
return 1;
}
if(playerid != id) {
GetPlayerName(id,iName,sizeof(iName));
GetPlayerName(playerid,pName,sizeof(pName));
format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
SendClientMessage(id,PM_INCOMING_COLOR,Message);
PlayerPlaySound(id,1085,0.0,0.0,0.0);
printf("PM: %s",Message);
}
else {
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
}
return 1;
}*/
if (strcmp("/komande", cmdtext, true, 10) == 0)
{
if(eng[playerid] == 1 ) return ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Help","/afk /back /kill /drogapomoc /admins /report /kucapomoc /givecash /rob /me /prekini","OK","Cancel");
else
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Pomoc","/afk /back /kill /drogapomoc /admins /report /kucapomoc /givecash /rob /me /prekini","OK","Odustani");
return 1;
}
if (strcmp("/kucnavozila", cmdtext, true, 10) == 0)
{
if(eng[playerid] == 1 ) return ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"House Vehicles help","Infernus\nNRG-500\nTurismo\nBullet\nCheetah\nBanshee\nHotring\nMonster","OK","Cancel");
else
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Dostupna kucna vozila","Infernus\nNRG-500\nTurismo\nBullet\nCheetah\nBanshee\nHotring\nMonster","OK","Odustani");
return 1;
}
if (strcmp("/afk", cmdtext, true, 10) == 0)
{
TogglePlayerControllable(playerid,0);// FREEZE
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "AFK ", "Sada si AFK kada se vratis napisi /back kako bi se odmrznuo...", "OK", "Odustani");
SendClientMessage(playerid, 0xFF0005FF,"Sada si AFK kada se vratis napisi /back kako bi se odmrznuo...");
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Je AFK sada, nemoj ga PM",name);
SendClientMessageToAll(0x00FF0AFF,string);
return 1;
}
if (strcmp("/back", cmdtext, true, 10) == 0)
{
TogglePlayerControllable(playerid,1);// UNFREEZE
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "AFK", "Dobrodosao natrag.", "Hvala", "Izadi");
SendClientMessage(playerid, 0xFF0005FF,"Dobrodosao nazad!");
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s Vise nije AFK",name);
SendClientMessageToAll(0x00FF0AFF,string);
return 1;
}
if(strcmp(cmd, "/givecash", true) == 0) {
new string[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "Napisi: /givecash [ID] [Iznos]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "Napisi: /givecash [ID] [Iznos]");
return 1;
}
moneys = strval(tmp);
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys) {
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "Poslao si %s(ID: %d), $%d.", giveplayer,giveplayerid, moneys);
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "Primio si $%d od %s(ID: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
printf("%s(ID:%d) je prenio %d za %s(ID:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else {
SendClientMessage(playerid, COLOR_YELLOW, "Netocan iznos!");
}
}
else {
format(string, sizeof(string), "%d nije aktivan igrac!", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}
if(strcmp("/moli", cmdtext, true) == 0)
{
if(spamblocker[playerid] == 1 ) return SendClientMessage(playerid ,0xFF0000FF, "Moras pricekati 30 sekundi prije nego opet koristis ovu komandu.");
else
if(PlayerToPoint(5.0,playerid,2490.2896,918.3433,11.0234))
{
SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
TogglePlayerControllable(playerid,0);
SetTimerEx("Molitva", 30000, false, "d",playerid);
spamblocker[playerid] = 1;
}
return 1;
}
if(strcmp("/molitva", cmdtext, true) == 0)
{
if(spamblocker2[playerid] == 1 ) return SendClientMessage(playerid ,0xFF0000FF, "Moras pricekati 30 sekundi prije nego opet koristis ovu komandu.");
else
if(PlayerToPoint(5.0,playerid,1454.1189,751.7510,11.0234))
{
SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
TogglePlayerControllable(playerid,0);
SetTimerEx("Molitva2", 30000, false, "d",playerid);
spamblocker2[playerid] = 1;
}
return 1;
}
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid,0);
SetPlayerArmour(playerid,0);
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s je napisao /kill i tako pocinio samoubojstvo.",name);
SendClientMessageToAll(0xFF0A00FF,string);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
return 1;
}
if(strcmp("/pecaj", cmdtext, true, 10) == 0)
{
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(spamblocker4[playerid] == 1 ) return SendClientMessage(playerid ,0xFF0000FF, "Moras pricekati neko vrijeme prije nego opet koristis ovu komandu.");
else if(modelid != 472 && modelid != 473 && modelid != 493 && modelid != 595 && modelid != 484 && modelid != 430 && modelid != 453 && modelid != 452 && modelid != 446 && modelid != 454) return SendClientMessage(playerid,0xFF0000FF,"Moras biti u brodu!");
else
{
TogglePlayerControllable(playerid,0);// FREEZE
spamblocker4[playerid] = 1;
SetTimerEx("Pecanje", 10000, false, "d",playerid);
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Pecanje","Pricekaj 10 sekundi dok ne upecas!","OK","Odustani");
}
return 1;
}
if(strcmp("/pljacka", cmdtext, true) == 0)
{
if(spamblocker3[playerid] == 1 ) return SendClientMessage(playerid ,0xFF0000FF, "Moras pricekati neko vrijeme prije nego opet koristis ovu komandu.");
else
if(PlayerToPoint(5.0, playerid, 361.7200,177.4187,1008.3828))
{
spamblocker3[playerid] = 1;
TogglePlayerControllable(playerid,0);// FREEZE
SendClientMessage(playerid,0x00FF0AFF,"Pricekaj 30 sekundi dok ne opljackas banku!");
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s je upravo poceo pljackati Las Venturas banku",name);
SendClientMessageToAll(0xFF0A00FF,string);
SetTimerEx("Pljacka", 30000, false, "d",playerid);
return 1;
}
}
if (strcmp("/drogapomoc", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Droga pomoc","Ako nemozes pronaci drug market napisi /kill i odi do mjesta gdje pise >generalna pomoc< i pogleda TUTORIAL\nCijene droga su od 500$ do 10,000$\nKada kupis drogu, ekran ti se pocinje micati ljevo/desno, a gotovo je nemoguce upravljati vozilom.","OK","Odustani");
return 1;
}
if (strcmp("/kart", cmdtext, true, 10) == 0)
{
if(PlayerToPoint(5.0, playerid, 2093.7246,1657.0605,10.8203))
{
SetPlayerPos(playerid,2456.6619,2490.0999,21.8750);
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s se prikljucio na kart race",name);
SendClientMessageToAll(0xFFF000FF,string);
return 1;
}
}
if (strcmp("/kucapomoc", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Kuce pomoc","/setrent [0/1] [Cijena]\n/ordercar [ImeVozila]\n/getrent\n/lock\n/unlock\n/payrent\n/unrent\n/rent","OK","Odustani");
return 1;
}
if (strcmp("/pravila", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,0x00FF0AFF,"Pricekaj 10 sekundi, nakon toga lista pravila ce se maknuti.");
SetTimerEx("Pravila", 10000, false, "d",playerid);
TextDrawShowForPlayer(playerid, Pravila1);
TextDrawShowForPlayer(playerid, Pravila2);
TextDrawShowForPlayer(playerid, Pravila3);
TextDrawShowForPlayer(playerid, Pravila4);
TextDrawShowForPlayer(playerid, Pravila5);
TextDrawShowForPlayer(playerid, Pravila6);
TextDrawShowForPlayer(playerid, Pravila7);
TextDrawShowForPlayer(playerid, Pravila8);
return 1;
}
if (strcmp("/fpomoc", cmdtext, true, 10) == 0)
{
if(PlayerToPoint(5.0,playerid,2281.2961,552.3666,7.7813))
{
SetTimerEx("FishPomoc", 5000, false, "d",playerid);
SetPlayerCameraPos(playerid, 2270.6094,569.9413,25.2396);
SetPlayerCameraLookAt(playerid, 2281.2961,552.3666,7.7813);
SetPlayerPos(playerid,2281.2961,552.3666,7.7813);
TogglePlayerControllable(playerid,0);// FREEZE
TextDrawShowForPlayer(playerid, fpomoc1);
TextDrawShowForPlayer(playerid, fpomoc2);
TextDrawShowForPlayer(playerid, fpomoc3);
}
return 1;
}
if(strcmp("/prekini", cmdtext, true) == 0)
{
if(gledatut[playerid] == 0 ) return SendClientMessage(playerid ,0xFF0000FF, "Ne gledas tutorial kako bi ga mogao prekinuti | ili si ga prekinuo prije 2 min pa nemozes opet!");
{
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s je prekinuo gledanje tutoriala",name);
SendClientMessageToAll(0x00FF0AFF,string);
SetPlayerVirtualWorld(playerid,0);
gledatut[playerid] = 0;
TogglePlayerControllable(playerid,1);// UNFREEZE
PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
SetCameraBehindPlayer(playerid);
SetPlayerPos(playerid,2168.6494,1406.7350,10.8203);
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Prekid tutoriala","Prekinuo si gledanje EFS tutoriala nadam se da si bar nesto naucio o nasem serveru\nAko ce ti opet trebati pomoc slobodno dodi i pogledaj ga opet.","OK","Odustani");
//SAKRI
TextDrawHideForPlayer(playerid,tut1);
TextDrawHideForPlayer(playerid,tut2);
TextDrawHideForPlayer(playerid,tut3);
TextDrawHideForPlayer(playerid,tut4);
TextDrawHideForPlayer(playerid,tut5);
TextDrawHideForPlayer(playerid,tut6);
TextDrawHideForPlayer(playerid,tut7);
TextDrawHideForPlayer(playerid,tut8);
TextDrawHideForPlayer(playerid,tut9);
TextDrawHideForPlayer(playerid,tut10);
TextDrawHideForPlayer(playerid,tut11);
TextDrawHideForPlayer(playerid,tut12);
TextDrawHideForPlayer(playerid,tut13);
TextDrawHideForPlayer(playerid,tut14);
TextDrawHideForPlayer(playerid,tut15);
TextDrawHideForPlayer(playerid,tut16);
TextDrawHideForPlayer(playerid,tut17);
TextDrawHideForPlayer(playerid,tut18);
TextDrawHideForPlayer(playerid,tut19);
TextDrawHideForPlayer(playerid,tut20);
TextDrawHideForPlayer(playerid,tut21);
TextDrawHideForPlayer(playerid,tut22);
TextDrawHideForPlayer(playerid,tut23);
TextDrawHideForPlayer(playerid,tut24);
TextDrawHideForPlayer(playerid,tut25);
TextDrawHideForPlayer(playerid,tut26);
TextDrawHideForPlayer(playerid,tut27);
TextDrawHideForPlayer(playerid,tut28);
TextDrawHideForPlayer(playerid,tut29);
TextDrawHideForPlayer(playerid,tut30);
TextDrawHideForPlayer(playerid,tut31);
TextDrawHideForPlayer(playerid,tut32);
TextDrawHideForPlayer(playerid,tut33);
}
return 1;
}
if (strcmp("/tutorial", cmdtext, true, 10) == 0)
{
if(PlayerToPoint(5.0,playerid,2172.0872,1398.5747,11.0625))
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Extreme Fun Server [TUTORIAL]","Za prekidanje tutoriala napisi /prekini","OK","Odustani");
gledatut[playerid] = 1;
SendClientMessage(playerid,0x00FF0AFF,"::::> Za prekidanje tutoriala napisi /prekini");
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s gleda tutorial.",name);
SendClientMessageToAll(0x00FF0AFF,string);
SetPlayerVirtualWorld(playerid,1);
PlayerPlaySound(playerid, 1097, 0.0,0.0,0.0);
SetTimerEx("Tutorial1", 20000, false, "d",playerid);
TogglePlayerControllable(playerid,0);// FREEZE
SetPlayerCameraPos(playerid, 2044.9576,1292.2585,70.4365);
SetPlayerPos(playerid,2034.8428,1306.9465,64.0852);
SetPlayerCameraLookAt(playerid, 2291.1248,1286.5923,70.4365);
TextDrawShowForPlayer(playerid, tut1);
TextDrawShowForPlayer(playerid, tut2);
TextDrawShowForPlayer(playerid, tut3);
TextDrawShowForPlayer(playerid, tut4);
TextDrawShowForPlayer(playerid, tut5);
TextDrawShowForPlayer(playerid, tut6);
}
return 1;
}
return SendClientMessage(playerid, 0xF50000FF, "/komande ili /pomoc > netocna komanda");
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd (fill, 4, cmdtext);
dcmd (tutorial, 8, cmdtext);
dcmd (prekini, 7, cmdtext);
dcmd (fpomoc, 6, cmdtext);
dcmd (pravila, 7, cmdtext);
dcmd (kucapomoc, 9, cmdtext);
dcmd (kart, 4, cmdtext);
dcmd (drogapomoc, 10, cmdtext);
dcmd (pljacka, 7, cmdtext);
dcmd (pecaj, 5, cmdtext);
dcmd (kill, 4, cmdtext);
dcmd (moli, 4, cmdtext);
dcmd (molitva, 7, cmdtext);
//dcmd (givecash, 8, cmdtext);
dcmd (afk, 3, cmdtext);
dcmd (back, 4, cmdtext);
dcmd (kucnavozila, 11, cmdtext);
dcmd (komande, 7, cmdtext);
dcmd (pm, 2, cmdtext);
dcmd (pomoc, 5, cmdtext);
dcmd (buyfuel, 7, cmdtext);
dcmd (usefuel, 7, cmdtext);
dcmd(rob, 3, cmdtext);
dcmd(napunisve, 9, cmdtext);
dcmd(me, 2, cmdtext);
return SendClientMessage(playerid, 0xF50000FF, "/komande ili /pomoc > netocna komanda");
}