PDA

View Full Version : Sscanf disconnect and reconnect problem


Face9000
12/08/2013, 10:36 PM
Before i start the core of the topic, i say i have the newest version of sscanf (include + plugin). Here is the problem:

Player with every id (doesnt matter which) joins for the first time, i do some admin commands on him as test, such as like /get, /goto and shit. They work all.

Player with every id quits, then reconnect, i try again this admin cmds on him, NONE OF THEM WORKS.

How damn is possible?

Lemme re-explain: If a player joins, and i use some admin commands on him such as goto, get, slap, explode etc, the first time the player joined everything works, but if he quits and rejoin, it doesnt.

I keep getting "Enter a valid playerid/name" like the player isn't connected but IT IS!

How i can resolve this? I remember i had again this problem times ago but i don't remember how i fixed it.

Any help is welcome.

Scenario
12/08/2013, 11:02 PM
You posted in the scripting help section. Where's the code for people to look at? There's obviously a pattern in your commands...

Face9000
13/08/2013, 09:40 AM
You posted in the scripting help section. Where's the code for people to look at? There's obviously a pattern in your commands...

The problem affects all commands.

Scenario
13/08/2013, 03:47 PM
All admin commands, or just the ones you've tested?

-Prodigy-
13/08/2013, 03:58 PM
Could you double check you actually have the latest sscanf version? If I remember, there was a bug on an early version that caused this.

Also, can you provide a command to see?

Face9000
13/08/2013, 06:23 PM
Could you double check you actually have the latest sscanf version? If I remember, there was a bug on an early version that caused this.

Also, can you provide a command to see?

I use the latest sscanf version, i checked 10 minutes ago.

All admin commands, or just the ones you've tested?

ALL admin commands that requires a parameter (like playerid or name).

ReVo_
13/08/2013, 06:30 PM
Post just one command please, just to see if you do something wrong.

Face9000
13/08/2013, 06:36 PM
Post just one command please, just to see if you do something wrong.

This is the most basic command in my admin commands list:


CMD:get(playerid, params[])
{
if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
if(pInfo[playerid][Admin] >= 2)
{
new target;
if(sscanf(params, "u", target)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/get [playerid]");
else if(target == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
if(!IsPlayerInAnyVehicle(target)) SetPlayerPosEx(target, Pos[0] + 2, Pos[1] + 2, Pos[2] + 2);
else SetVehiclePos(GetPlayerVehicleID(target), Pos[0] + 2, Pos[1] + 2, Pos[2] + 2);
SetPlayerInterior(target, GetPlayerInterior(playerid));
if(IsPlayerInAnyVehicle(target)) LinkVehicleToInterior(GetPlayerVehicleID(target), GetPlayerInterior(playerid));
SetPlayerVirtualWorld(target, GetPlayerVirtualWorld(playerid));
if(IsPlayerInAnyVehicle(target)) SetVehicleVirtualWorld(GetPlayerVehicleID(target), GetPlayerVirtualWorld(playerid));
pInfo[target][AdminActions]++;
}
return 1;
}


I remember i had this problem before but i forgot how damn i fixed...

Scenario
13/08/2013, 06:36 PM
Do all of your admin commands have a similar structure? I'm going to assume that SOMETHING other than the sscanf line in your commands is messing it all up. Post some of the commands for crying out loud- quit being so freaking difficult.

#e:

if(sscanf(params, "u", target)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/get [playerid]");
else if(target == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");
Replace that, with this:

if(sscanf(params, "u", target)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/get [playerid]");
if(target == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");

Face9000
13/08/2013, 07:13 PM
Do all of your admin commands have a similar structure? I'm going to assume that SOMETHING other than the sscanf line in your commands is messing it all up. Post some of the commands for crying out loud- quit being so freaking difficult.

#e:

if(sscanf(params, "u", target)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/get [playerid]");
else if(target == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");
Replace that, with this:

if(sscanf(params, "u", target)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/get [playerid]");
if(target == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");

No, not all have this structure, and i like my code style, why i should change lol.

However, another admin commands:


CMD:goto(playerid, params[])
{
if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
if (pInfo[playerid][Admin] >= 1)
{
new targetid, string[128];
if(sscanf(params, "u", targetid)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/goto [PlayerID]");
if(targetid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_ORANGE, "Enter a valid player ID/name!");
if(GetPVarInt(playerid,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
else
{
new pName[24];
GetPlayerName(targetid,pName,128);
new aName[24];
GetPlayerName(playerid,aName,128);
format(string, sizeof(string), "You succesfully teleported to %s [%d]",pName,targetid);
SCM(playerid,0xFF0000FF,string);
SetPlayerInterior(playerid,GetPlayerInterior(targe tid));
new Float:TeleX, Float:TeleY, Float:TeleZ;
GetPlayerPos(targetid, TeleX, TeleY, TeleZ);
SetPlayerPosEx(playerid, TeleX, TeleY, TeleZ);
new msg[128];
format(msg, sizeof(msg), "0,4** Admin %s (%d) teleported to %s (%d)", aName,playerid, pName, targetid);
IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
SetPVarInt(playerid,"CmdTime",GetTickCount()+2000);
pInfo[targetid][AdminActions]++;
return true;
}
}
else return 0;
}

CMD:drop(playerid, params[])
{
if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
if (pInfo[playerid][Admin] >= 1)
{
new pid;
if(sscanf(params, "u", pid)) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/drop [PlayerID]");
if(!IsPlayerConnected(pid)) return SCM(playerid, red, "ERROR: That player is not online.");
if(pid == playerid) return SCM(playerid, COLOR_RED, "You can't drop yourself.");
if(GetPVarInt(playerid,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
new Float:x;
new Float:y;
new Float:z;
new msg[250];
new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[250];
GetPlayerName(pid, paramname, sizeof(paramname));
GetPlayerName(playerid, adminname, sizeof(adminname));
GetPlayerPos(pid,x,y,z);
SetPlayerPosEx(pid,x,y,z+20);
format(string, sizeof(string), "** Admin %s (%d) dropped %s (%d)", adminname,playerid, paramname, pid);
SendMessageToAdmins(0xFF0000FF, string);
SetPVarInt(playerid,"CmdTime",GetTickCount()+2000);
pInfo[pid][AdminActions]++;

format(msg, sizeof(msg), "0,4** Admin %s (%d) dropped %s (%d)", adminname,playerid, paramname, pid);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
}
else SCM(playerid, red, "Unknown command.");
return 1;
}

CMD:mute(playerid, params[])
{
if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
if (pInfo[playerid][Admin] >= 1)
{
new pid;
new msg[128];
if(sscanf(params, "us", pid, params[2])) return SCM(playerid, -1, "{F70505}Usage: {FFFFFF}/mute [playerid] [reason]");
if(pInfo[pid][Muted] == 1) return SCM(playerid,0xFF0000FF,"This player is already muted.");
if(pid == playerid) return SCM(playerid, COLOR_RED, "You can't mute yourself.");
if(!IsPlayerConnected(pid)) return SCM(playerid, red, "ERROR: That player is not online.");
new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
GetPlayerName(pid, paramname, sizeof(paramname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string, sizeof(string), "** Admin %s (%d) muted %s (%d) - (%s)", adminname,playerid, paramname, pid, params[2]);
SCMTA(0xFF0000FF, string);
pInfo[pid][Muted] = 1;
pInfo[pid][AdminActions]++;
format(msg, sizeof(msg), "0,4** Admin %s (%d) muted %s (%d) - (%s)", adminname,playerid, paramname, pid, params[2]);
IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
}
else SCM(playerid, red, "Unknown command.");
return 1;
}

Scenario
13/08/2013, 07:21 PM
if(something == value) return 1;
else if(something == value) return 1;
That's just redundant. If the first if-statement checks out (as in something = value), then it's going to return 1 and end the processing for that particular command/function. Meaning, it can't move on to the else-if statement even if it wanted to; you've skipped it. Therefore, there's no point in having "else" there. If the if-statement is going to return something, it will; otherwise it's ALWAYS going to run another check.

I structure my commands like this:

if(something)
return 1;
if(somethingelse)
return 1;

// code goes here; the if statements above passed all checks and we can perform whatever code we need
Unless you're not using the latest version of sscanf, or if you've modified it, then this shouldn't be happening. I would look for patterns in your commands (like I've said 5 times) because there's something in each one that's causing this. I've NEVER had this issue with sscanf.

By the way, drop your attitude.

Face9000
13/08/2013, 07:23 PM
Yes, i know, many people hate my attitude but i dont care.

I'll look better in the admin commands.