PDA

View Full Version : /exit not working.


TheTerminator
13/11/2011, 01:06 PM
So, I made this /exit command, my /enter command is working fine, it TP's me to the interior and the position, when i try to /exit the interior, nothing, not even: "[SERVER]Unknown Command"... I tried everything, browsed youtube, this forum, ******, nothing... This is the code:

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812));
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}

If anyone has ideas, respond quickly, thanks!

wumpyc
13/11/2011, 01:07 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812));
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
"if" was mising

TheTerminator
13/11/2011, 01:09 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812));
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
"if" was mising


"error 036: empty statement"


public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812));
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}



EDIT: FIxed that, but still not working :confused: I had to remove the ";" from if(IsPlayer...) But yet, it aint workin' --''

wumpyc
13/11/2011, 01:12 PM
Ok, this should work now...
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
}
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
{
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
}
return 1;
}
return 0;
}

KosmasRego
13/11/2011, 01:12 PM
The last return 1; is return 0;

TheTerminator
13/11/2011, 01:13 PM
error 010: invalid function or declaration 3x this error :O

Kwarde
13/11/2011, 01:14 PM
First of all: After an 'if' statement you shouldn't add a decilla. That is this one: ;
Secondly: If the command after the statement has more then one lines you should use these brackets: {}
The fixed version is here:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/exit", cmdtext, true, 5) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
}
return 1;
}
if(strcmp("/enter", cmdtext, true, 6) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
{
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
}
return 1;
}

wumpyc
13/11/2011, 01:14 PM
error 010: invalid function or declaration 3x this error :O
Just copy my last post, i don't get any error.

TheTerminator
13/11/2011, 01:15 PM
I put return 0; and still not working :confused: help!


this is the whole code for cmd:

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 1;
}
if (strcmp("/teleport", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
return 1;
}
return 0;
}

antonio112
13/11/2011, 01:18 PM
You sure you have the correct coordinates? I don't see anything wrong with the command ...

Or, try the next thing:


if (strcmp("/exit", cmdtext, true, 5) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}

Kwarde
13/11/2011, 01:18 PM
Try this:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/exit", cmdtext, true, 5) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
}
return 1;
}
if(strcmp("/enter", cmdtext, true, 6) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
{
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
}
return 1;
}
if(strcmp("/teleport", cmdtext, true, 9) == 0)
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
return 1;
}
return SendClientMessage(playerid, 0xFF0000AA, "That command doesn't exists!");
}

NOTE: If you want the standard "SERVER: Unknown command", replace the return SendClientMessage(playerid, 0xFF0000AA, "That command doesn't exists!"); with return 0;
It didn't work because you closed the OnPlayerCommandText after the /enter command (that bracket beneath the return 1;). Removing that will also work.

TheTerminator
13/11/2011, 01:18 PM
I still get the same error 3 times: invalid function or declaration
149) : error 010: invalid function or declaration
(147) : error 010: invalid function or declaration
(144) : error 010: invalid function or declaration

KosmasRego
13/11/2011, 01:19 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812)
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844)
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 1;
}
if (strcmp("/teleport", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
return 1;
}
return 0;
}

Kwarde
13/11/2011, 01:20 PM
Did you try my script already? - That one is just correct. If you did try mine, you must have made a mistake somewhere else.
If you want me to fix it, send me your gamemode over PM (paste script in pastebin.com then please) and I'll see what I can do.
Otherwise, please show lines 149, 147 and 144

EDIT:
@KosmasRego:
Do not post wrong scripts! - Or test it first. That one won't work. You have one wrong bracket!

EDIT 2:
@KosmasRego: Check the post below me: He's seen it too :P

antonio112
13/11/2011, 01:20 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812)
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844)
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 1;
}
if (strcmp("/teleport", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
return 1;
}
return 0;
}


You have no clue of what you're doing, right?

KosmasRego
13/11/2011, 01:21 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 0;
}

try this

Kwarde
13/11/2011, 01:22 PM
Do you even check other posts? I've posted the same already -.-".
http://forum.sa-mp.com/showpost.php?p=1516812&postcount=11

TheTerminator
13/11/2011, 01:22 PM
http://pastebin.com/i0aZy3rJ


You didnt get my point, the problem is the /exit command does not work, not that I want the "Unknown command"
I get IG, type it, and nothing, not even the "Unknown cmd" thing :S

KosmasRego
13/11/2011, 01:23 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 384.808624,173.804992,1008.382812))
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 0;
}

try this
try this...

Kwarde
13/11/2011, 01:24 PM
Do you even read whole posts - As I've told already: One bracket is placed while it shouldn't even be placed. Remove the bracket (This char: }) at line 141 and it's fixed. Then you'll get 2 warnings, unreachable codes. Just remove those lines too. Eg. remove also "return 1;" on line 140

EDIT:
The fixed script:
http://pastebin.com/4xsdFsbt

antonio112
13/11/2011, 01:25 PM
Here you have it:

http://pastebin.com/TR9Y1GAd

KosmasRego
13/11/2011, 01:26 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, 384.808624,173.804992,1008.382812))
SetPlayerPos(playerid, 2302.9736,-53.8796,26.4844);
SetPlayerInterior(playerid, 0);
return 1;
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 6.0, 2302.9736,-53.8796,26.4844))
SetPlayerPos(playerid, 384.808624,173.804992,1008.382812);
SetPlayerInterior(playerid, 3);
return 1;
}
return 0;
}

let's try this one

Kwarde
13/11/2011, 01:26 PM
KosmasRego for christ's sake read posts! I have fixed it all already, and you only are removing something that was working -.-.
Here is the link to the post once more: http://pastebin.com/4xsdFsbt

EDIT:
@antonio: -.-'':
Do you even read whole posts - As I've told already: One bracket is placed while it shouldn't even be placed. Remove the bracket (This char: }) at line 141 and it's fixed. Then you'll get 2 warnings, unreachable codes. Just remove those lines too. Eg. remove also "return 1;" on line 140

EDIT:
The fixed script:
http://pastebin.com/4xsdFsbt

TheTerminator
13/11/2011, 01:27 PM
http://pastebin.com/QgEfQmzY check this one out, its the non-edited due to me screwing it up. Now tell me what to fix.

antonio112
13/11/2011, 01:28 PM
http://pastebin.com/QgEfQmzY check this one out, its the non-edited due to me screwing it up. Now tell me what to fix.

Dude, you're not reading what we're posting here? My last post here, if you're interested in solving your problem, you have 3 pages already to read. See how it's been fixed.

Kwarde
13/11/2011, 01:29 PM
[CENSURED]. We've fixed it already. The working script is here:
Do you even read whole posts - As I've told already: One bracket is placed while it shouldn't even be placed. Remove the bracket (This char: }) at line 141 and it's fixed. Then you'll get 2 warnings, unreachable codes. Just remove those lines too. Eg. remove also "return 1;" on line 140

EDIT:
The fixed script:
http://pastebin.com/4xsdFsbt

EDIT:
Due of the annoying 2 minutes wait time, Antiono posted before me. There should be something that warns when someone has posted while you were making a post :P

TheTerminator
13/11/2011, 01:33 PM
[CENSURED]. We've fixed it already. The working script is here:


EDIT:
Due of the annoying 2 minutes wait time, Antiono posted before me. There should be something that warns when someone has posted while you were making a post :P

Here, http://pastebin.com/KvA5Z2B0, I've done waht you said, and got this :S

wumpyc
13/11/2011, 01:35 PM
Then you got wrong cords dude -.-

Kwarde
13/11/2011, 01:36 PM
Are you sure? It's working for me. Btw, the URL you gave me is different then mine. This here is the script:
http://pastebin.com/4xsdFsbt

TheTerminator
13/11/2011, 01:36 PM
I'm working on a script to get TP'ed into the planning department. I got the exact co-ordinates, the cord's are alright, :confused: I dont get this shit anymore --''

Kwarde
13/11/2011, 01:38 PM
Read the post above that post of yours. That is working! Or no, even better: This is the FULLY WORKING SCRIPT AGAIN: http://pastebin.com/4xsdFsbt

TheTerminator
13/11/2011, 01:38 PM
@Kwarde, I got this warnings, I did exactly what you wrote:
(140) : warning 217: loose indentation
(145) : warning 217: loose indentation

Tell me what you edited, and I'll edit it too, >:(

Kwarde
13/11/2011, 01:41 PM
Then it should be a bug with pastebin: I don't have that. Some tabs must've been fucked up once it was uploaded. The loose indentation simply means that the script looks ugly :P.
"Good indentation":

new var1 = 1, var2 = 5;
if(var1 == var2)
{
print("var1 equals var2");
print(":D");
}
else
{
print("var1 doesn't equal var2");
print("That sux");
}

Bad indentation:

new var1 = 1, var2 = 5;
if(var1 == var2)
{
print("var1 equals var2");
print(":D");
}
else
{
print("var1 doesn't equal var2");
print("That sux"); //This is the bad indentation!
}


So you know what to do: If you have something like that, place them on the same place (one tab after the bracket). If you don't know what to do: The loosing indentation (AS FAR AS I KNOW) won't give problems ingame.

TheTerminator
13/11/2011, 01:48 PM
Thank you people for your time, I'm going to go ahead and test it IG, i fixed the loosing identation! pz.

TheTerminator
13/11/2011, 01:50 PM
Fuck damn, I fixed it everything, seems the cordinates dont work like someone said before. Here is the code from /save from the interior. I dont seriusly know what's wrong:
AddPlayerClass(0,389.2320,173.7243,1008.6323,271.7 116,0,0,0,0,0,0);

Kwarde
13/11/2011, 01:52 PM
Note: There is an edit button (this one: http://forum.sa-mp.com/images/buttons/edit.png - Use that one instead of double posting please, especially for yourself in due of warnings and stuff).
However, you might have the wrong interior ID (The one in SetPlayerInterior). Use the command /interior to see the interior (if you've had that one already, please tell me what interior you want and I'll take a look at it)

TheTerminator
13/11/2011, 01:55 PM
Interior number 3: Planning Department, I need cord's of the enterance when you /enter so you need those cord's for IsPlayerInRangeofpo....

Kwarde
13/11/2011, 01:56 PM
Hmm, I actually have no idea what the planning departement is xD
For the position where you wanna /enter it: You should do that yourself. Here is btw the interior list:
http://files.sa-mp.com/interiors.txt
(Format: ID InteriorID PosX PosY PosZ PosA Description).
The things you absolutely use are the InteriorID, PosX, PosY and the PosZ.

TheTerminator
13/11/2011, 01:59 PM
When I use that coordinates, lots of errors come, probably not good :S What my problem is the /exit command is not working, I dont got any idea what it is tbh. Maybe its wrong co-ordinates? :confused: ???

http://weedarr.wikidot.com/interior

Not fucking working, fuuck it -.-'

Kwarde
13/11/2011, 02:15 PM
Did you replace the spaces with comma's?
Eg. this:
0.0 5.3 7.8
should become:
0.0,5.3,7.8
or even better (to make it more readable):
0.0, 5.3, 7.8

EDIT:
Nevermind, weedarr doesn't have spaces for the positions.

wumpyc
13/11/2011, 02:19 PM
use this to get position

CMD:mypos(playerid,params[])
{
new playerpos[200],Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
format(playerpos,sizeof(playerpos),"Your position is: X = %f Y = %f Z = %f",x,y,z);
SendClientMessage(playerid,0x00FF00FF,playerpos);
return 1;
}

Kwarde
13/11/2011, 02:33 PM
What about this one: This will save the location (XYZ + Angle pos, Interior + Virtual World) to "scriptfiles/saves_positions.txt" with the commands (USING ZCMD+SSCANF2!!!):

CMD:savepos(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new commentStr[50], Float:pPos[4], File:posSave, saveStr[500];
if(sscanf(params, "s[50]", commentStr)) SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /savepos [comment]");
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
GetPlayerFacingAngle(playerid, pPos[3]);
posSave = fopen("saved_positions.txt", io_append);
format(saveStr, 500, "SetPlayerPos(playerid, %f, %f, %f); //%s\r\n", pPos[0], pPos[1], pPos[2], commentStr);
fwrite(posSave, saveStr);
format(saveStr, 500, "SetPlayerFacingAngle(playerid, %f);\r\nSetPlayerInterior(playerid, %d);\r\nSetPlayerVirtualWorld(playerid, %d);\r\n\r\n", pPos[3], GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
fwrite(posSave, saveStr);
fclose(posSave);
return 1;
}

(Don't look at the size of saveStr please :P - 500... o_O

TheTerminator
13/11/2011, 02:35 PM
I'm doing this for another server, I mapped a library, in the Planning Department. I made the /enter & /exit command. /enter puts me into the building, then I try to /exit, nothing. Its probably because of the co-ordinates, I dont know what's wrong with them. The interior is "Planning Department", Interior ID 3. I need to get the co-ordinates. Thanks.

mamorunl
13/11/2011, 03:36 PM
Why not do it more efficiently? Stop checking for your coordinates and just add a variable that sets you inside the building:


new isInBuilding=false;

and then at your /enter: isInBuilding=true;
your /exit: if(isInBuilding == true) { // teleport outside with SetPlayerPos and:
isInBuilding = false; }