25.01.2013, 19:41
(
Last edited by Roach_; 25/01/2013 at 08:56 PM.
)
ZCMD:
STRCMP:
PS: For strcmp you need:
This function:
To add this to the OnPlayerCommandText callback(at the beginning of the callback):
Depends on what Save System are you using..
pawn Code:
CMD:eject(playerid, params[])
{
new uID;
if(sscanf(params, "u", uID)) return SendClientMessage(playerid, -1,"Usage: /eject [playerid]");
if(!IsPlayerConnected(uID)) return SendClientMessage(playerid, -1, "ERROR: This player isn't connected");
if(!IsPlayerInAnyVehicle(uID)) return SendClientMessage(playerid, -1, "ERROR: The player isn't in any vehicle");
new Float:xposs, Float:y, Float:z;
RemovePlayerFromVehicle(uID);
GetPlayerPos(uID, xposs, y, z);
SetPlayerPos(uID, xposs, y, z + 3);
SendClientMessage(uID, -1, "You have been ejected from the vehcile");
SendClientMessage(playerid, -1, "Player ejected");
return 1;
}
pawn Code:
if(!strcmp(cmdtext, "/eject", true))
{
new tmp[128], uID;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1,"Usage: /eject [playerid]");
uID = strval(tmp);
if(!IsPlayerConnected(uID)) return SendClientMessage(playerid, -1, "ERROR: This player isn't connected");
if(!IsPlayerInAnyVehicle(uID)) return SendClientMessage(playerid, -1, "ERROR: The player isn't in any vehicle");
new Float:xposs, Float:y, Float:z;
RemovePlayerFromVehicle(uID);
GetPlayerPos(uID, xposs, y, z);
SetPlayerPos(uID, xposs, y, z + 3);
SendClientMessage(uID, -1, "You have been ejected from the vehcile");
SendClientMessage(playerid, -1, "Player ejected");
return 1;
}
This function:
pawn Code:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
pawn Code:
new cmd[128], idx;
cmd = strtok(cmdtext, idx);