GetPlayerID doesn't works
#1

Hy!
I have tried to create something with function GetPlayerID, but doesnt works
Here is the function
Код:
stock GetPlayerID(gstring[])
{
    for(new i = 0; i <= GetMaxPlayers(); i++)
    {
    if(IsPlayerConnected(i) == 1)
    {
        new testname[MAX_PLAYER_NAME];
        GetPlayerName(i, testname, sizeof(testname));
        if(strcmp(testname, gstring, true, strlen(gstring)) == 0)
        {
            return i;
        }
    }
}
return INVALID_PLAYER_ID;
}
And here is the code:
Код:
vehInfo[vehid][IsAtMechanicHQ]=1;
format(string,128,"You have set a wheelclamped to %s's car.",vehInfo[vehid][vownername]);
SendClientMessage(playerid,COLOR_GREEN,string);
dUserSetINT(vehInfo[vehid][vownername]).("PlayerVehicleIsAtMechanicHQ",1);
new aplayerid = GetPlayerID(vehInfo[vehid][vownername]);
if(aplayerid > INVALID_PLAYER_ID)
{
SendClientMessage(aplayerid,COLOR_RED, "To your car has been set a wheelclamped!");
VehicleInfo[aplayerid][PlayerVehicleIsAtMechanicHQ]=1;
}
If i do this with name Bart it wrotes: "You have wheelclamped Bart's car", it sets to my dini PlayerVehicleIsAtMechanicHQ to 1,but it doesn't sends me the message: "to your car has been set a wheelclamped"

Please help me
Reply
#2

Код:
INVALID_PLAYER_ID = 65535
so should be

Код:
if(aplayerid != INVALID_PLAYER_ID)
or

Код:
if(aplayerid < INVALID_PLAYER_ID)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)