Also, ich habe jetzt folgendes Script:
public timer(playerid) {
if(GetPVarInt(playerid,"Var1") == 0) {
if(gettime()-pHoldingTime[playerid]>=8) SetPVarInt(playerid,"Var1",1); TogglePlayerControllable(playerid,false);
}
return 1;
}
ocmd:test(playerid,params[])
{
SetPVarInt(playerid,"test",1);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPVarInt(playerid,"test") == 1) {
if(HOLDING(KEY_YES)) {
pHoldingTime[playerid] = gettime();
testtimer[playerid]=SetTimerEx("timer",1000,1,"d",playerid);
}
if(RELEASED(KEY_YES)) {
new string[32];
format(string, sizeof string, "%d Sekunden", gettime()-pHoldingTime[playerid]);
SendClientMessage(playerid,-1,string);
KillTimer(testtimer[playerid]);
SetPVarInt(playerid,"Var1",0);
}
}
return 1;
}
Als ich dies nun getestet habe, wurde ich nach 2 Sekunden gefreezt, anstatt nach 8.