07.05.2011, 04:10
Can you be a bit more specific? Do you receive any client messages before the server crashes? Is there any sort of delay between you typing the command and the server shutting down?
By overlooking the code, I see you are missing some code. You never assign the tmp variable to a value. You are missing something like so:
Adding that after your check of whether or not the player is connected, will retrieve the first section of the string (cmdtext) after a space. For example, if you typed "/joinevent 55", the tmp variable would be assigned "55".
As for the server crashing, it could be due to the fact strval( ) is trying to retrieve a value that is either non-existent or is too big for it to handle. If I recall correctly, strval( ) can crash on large values. Try adding what I mentioned above, and come back with the results.
Also, as a tip, here are a couple things you should consider:
- Switching to ZCMD command processor
- Removing the IsPlayerConnected( ) checks from the commands
Switching to ZCMD would be a great thing for your mode, especially since you're using one of the slowest methods to execute the commands - strtok and strcmp - when you could be using ZCMD and sscanf2. Look them up, they are worth the time and effort to learn and convert to.
You also do not need the IsPlayerConnected( ) checks under OnPlayerCommandText callback, since now commands will simply not execute for non-connected players (Unless done by the script, I suppose).
By overlooking the code, I see you are missing some code. You never assign the tmp variable to a value. You are missing something like so:
pawn Код:
tmp = strtok( cmdtext, idx );
As for the server crashing, it could be due to the fact strval( ) is trying to retrieve a value that is either non-existent or is too big for it to handle. If I recall correctly, strval( ) can crash on large values. Try adding what I mentioned above, and come back with the results.
Also, as a tip, here are a couple things you should consider:
- Switching to ZCMD command processor
- Removing the IsPlayerConnected( ) checks from the commands
Switching to ZCMD would be a great thing for your mode, especially since you're using one of the slowest methods to execute the commands - strtok and strcmp - when you could be using ZCMD and sscanf2. Look them up, they are worth the time and effort to learn and convert to.
You also do not need the IsPlayerConnected( ) checks under OnPlayerCommandText callback, since now commands will simply not execute for non-connected players (Unless done by the script, I suppose).