13.04.2012, 20:45
Hey how can I create a const string for playerid, because I want it so when I do /givecarkeys it'll change the const string only for this specific playerid to another value.
How can I do it?
When I try to do this:
I get the errors:
On the line:
How can I do it?
When I try to do this:
PHP код:
new const Keys[MAX_PLAYERS] = 0;
CMD:givecarkeys(playerid, params[])
{
new pid, id, msg[128];
if(sscanf(params, "ud", pid, id)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /givecarkeys [player] [vehicleid]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_RED, "Invalid player!");
if(!IsValidVehicle(id)) return SendClientMessage(playerid, COLOR_RED, "Invalid vehicleid!");
if(GetPlayerVehicleAccess(playerid, id) < 1)
return SendClientMessage(playerid, COLOR_RED, "You are not the owner of this vehicle!");
if(!PlayerToPlayer(playerid, pid, 10.0)) return SendClientMessage(playerid, COLOR_RED, "Player is too far!");
SetPVarInt(pid, "CarKeys", id);
GetPlayerVehicleAccess(playerid, id = 2);
Keys[playerid] = 1;
format(msg, sizeof(msg), "You have given your car keys to %s (%d)", PlayerName(pid), pid);
SendClientMessage(playerid, COLOR_WHITE, msg);
format(msg, sizeof(msg), "%s (%d) has given you car keys", PlayerName(playerid), playerid);
SendClientMessage(pid, COLOR_WHITE, msg);
return 1;
}
PHP код:
C:\Documents and Settings\user\My Documents\Downloads\avs.pwn(1505) : error 022: must be lvalue (non-constant)
C:\Documents and Settings\user\My Documents\Downloads\avs.pwn(1505) : warning 215: expression has no effect
PHP код:
Keys[playerid] = 1;