Vice Underdogs
Scripting => Scripting Support => Topic started by: Zeke on October 24, 2011, 09:26:50 pm
-
So basicly the problem is the format message of the cmd its bugged.
example:
with player name typed; Officer [VU]aXXo suspected [VU_R]Zeke Reason: testke
with player ID typed; Officer [VU]aXXo suspected [VU_R]Zeke Reason: test
it add the last 2 (sometimes 3) letters of the suspects name
here is my script
else if(strcmp(cmd,"sus",true) == 0)
{
new plr;
tmp = strtok(cmdtext, idx);
plr = FindPlayerIDFromString(tmp);
new reason[256]; reason = strtok(cmdtext, idx);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
else if(PlayerInfo[playerid][Cop] != 1) SendClientMessage(playerid, COLOR_RED, "You are not a Police officer");
else if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c sus [Nick/ID] [Reason]");
else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Unknown player");
else if(PlayerInfo[plr][Wanted] >= 1) SendClientMessage(playerid,COLOR_RED,"Suspect is already wanted...");
else
{
new szMsg[256];
format(szMsg,sizeof(szMsg),"Officer %s suspected %s Reason:%s",gPlayers[playerid],gPlayers[plr],cmdtext[6]);
SendClientMessageToAll(COLOR_GREEN,szMsg);
new surmsg[256];
format(surmsg,sizeof(surmsg),"%s suspected you!!!",gPlayers[playerid]);
SendClientMessage(plr,COLOR_YELLOW,surmsg);
PlayerInfo[plr][Wanted] = 1;
}
return 1;
}
ye and i know what will all of u say "scrap it and convert it to squirrel" but NEIN ( personal reasons)
-
-------------- BEGIN HARSH CRITIQUE --------------
- Using 256 cells for everything.
You are really screwing your performance here, since you're using 768 cells for a command that just prints some text to chat. Use ONE string at about 128 cells and leave it at that. Reformat that string instead of declaring three unnecessarily huge strings.
- Use of strtok
Your suspection reason can be any number of words large. strtok only takes one word. strtok(cmdtext, idx, '`') should work.
- Based it off of GUPS
I could tell as soon as I saw strtok and PlayerInfo that you're using GUPS, which is the most overused script I have ever seen, and I am glad aXXo and I had moved Argo to Squirrel. Working with GUPS was a pain for large scripts. (https://viceunderdogs.com/proxy.php?request=http%3A%2F%2Fcommunity.secondlife.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F6299iDC1A1164915592DF%2Fimage-size%2Flarge%3Fv%3Dmpbl-1%26amp%3Bpx%3D600&hash=a124886e9b349342f5f0fa657d1947157c8f9bb2)
- Used Pawn
scrap it and convert it to squirrel
- The actual problem
format(szMsg,sizeof(szMsg),"Officer %s suspected %s Reason:%s",gPlayers[playerid],gPlayers[plr],cmdtext[6]);
Why are you using cmdtext[6]? Didn't you already define reason?
-------------- END HARSH CRITIQUE --------------
-
-------------------------------- Begin Rant --------------------------------
scrap it and convert it to squirrel" but JA ( personal reasons)
-------------------------------- End Rant --------------------------------